February 2, 2010 at 4:24 pm
Hi
I have a situation like below.
With CTE
(
Select * from a1
inner join a2
)
Select * from cte.
What i want here that i will need to place another CTE in place of a2 table.
is it possible?
Let me know if you need more information.
any help would be appreciated...
Thanks..
February 2, 2010 at 4:31 pm
Something like
With CTE as
(
Select a2.* from a1
inner join a2
on a1.col=a2.col
),
CTE2 as
(
Select a4.* from a3
inner join a4
on a3.col=a4.col),
CTE3 as
(
Select a5.* from CTE1
inner join a5
on CTE1.col=a5.col
)
Select cte3.* from cte
inner join CTE3
on cte.col=cte3.col
As you can see, you can even reference one cte within another cte.
All separate CTEs would be treated as subqueries, just easier to write... 😉
It's also possible to use recursive CTEs. For details, please see BOL (BooksOnLine).
February 2, 2010 at 5:08 pm
Thank you vey much for your time...
I will modify my code as you mentioned format.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply