In First Image Only Select Statement is run , it works fine .
but In Second Image when we added CTE and executed the query , it shows error.
Can you please help me with this ???
CodePudding user response:
It says Incorrect syntax near ';'
because you have a WITH
statement ended with a ;
and no further SELECT
after it.
The query itself is fine, that's why it works up top. But when using WITH
, you have to follow it up with more querying.
Delete the exiting ;
and ddd SELECT * FROM cte1;
after it.
CodePudding user response:
A CTE generate a image of a table, so you need to make a select
afterwards as well.
with cte1 (...) select * from cte1;