Multiple WITH temp tables


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.
Who is Participating?
MilleniumaireConnect With a Mentor Commented:
Yes, but you only use one WITH clause, but with multiple named statements


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

Open in new window

GerardMcLAuthor Commented:
Thank you for a very fast and very helpful reponse
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.