Multiple WITH temp tables

Hi,

I was wondering if it is possible to use multiple WITH temp AS tables within one sql query?
I am trying but get an error saying 'missing SELECT keyword' but the sql inside each WITH temp is ok.

Any help is appreciated or if you can point me towards a good resource on this subject.
GerardMcLAsked:
Who is Participating?
 
MilleniumaireConnect With a Mentor Commented:
Yes, but you only use one WITH clause, but with multiple named statements

eg.

WITH
temp as select .....
temp2 as select ...
main query
0
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
a bit more concrete, about the () ...
WITH temp as ( select ..... .... )
   , temp2 as ( select ... ... )
SELECT * 
  FROM temp
  JOIN temp2
    ON ...

Open in new window

0
 
GerardMcLAuthor Commented:
Thank you for a very fast and very helpful reponse
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.