Home > Blockchain >  The Query is not working when I am adding a CTE command to it , although the Inside Select Query is
The Query is not working when I am adding a CTE command to it , although the Inside Select Query is

Time:05-14

enter image description here

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;

  • Related