Last post Sep 06, 2010 08:08 PM by raghav_khunger
Sep 06, 2010 03:46 PM|isjf|LINK
this is sub query
select * from
this is CTE
With A (no,money,name) AS
I am just wondering... what is the difference between "CTE' and subquery?
when should I use CTE and when should I use subquery?
Sep 06, 2010 03:58 PM|ketan_al|LINK
Please refer following
hope this helps
Sep 06, 2010 04:01 PM|Naom|LINK
When you use CTE as a derived table, there is no difference between CTE and derived table. The difference is only from the readability/maintainability point of view. I prefer CTE to derived tables as the code is usually easier to read and understand.
Sep 06, 2010 07:55 PM|macpak|LINK
Additionally, CTE lets you create recursive queries.
Sep 06, 2010 08:08 PM|raghav_khunger|LINK
Yes in support to Naomi I prefer using CTE as readability and maintenance wise I found them good. Also yes the recursion feature of CTE is a great one I wrote a blog on this before , you can refer this: