Reputation: 41
as sample code below....
WITH sampleA as (SELECT * FROM emp)
SELECT * FROM sampleA
SELECT * FROM sampleA
this alias 'sampleA' will work for only first query not for second or later..
But I want to query more with this alias only.
Can you please help me, how can I do that?
Upvotes: 4
Views: 2382
Reputation: 28741
Common table Expression scope is limited to first SELECT statement. For multiple usage , use instead temporay table or table variable.
Upvotes: 2