4

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?

Justin
  • 885
  • 9
  • 19

1 Answers1

2

Common table Expression scope is limited to first SELECT statement. For multiple usage , use instead temporay table or table variable.

Mudassir Hasan
  • 28,083
  • 20
  • 99
  • 133