Question : uese cte twice in a query

I trying to use a cte twice in same query and i am getting error in second selecte statement.
if the comment the firts select it works. How can i use same cte twice in my query? please help
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
;with cte as
(
select * from  c
inner join  r on
r.rid = c.id
where r.fid = 11111)

select * from  s  
inner join cte on
cte.rid=s.rid

select * from o  
inner join cte on
cte.roomid=o.rid

Answer : uese cte twice in a query

http://msdn.microsoft.com/en-us/library/ms175972.aspx

A CTE must be followed by a single SELECT, INSERT, UPDATE, MERGE, or DELETE statement that references some or all the CTE columns. A CTE can also be specified in a CREATE VIEW statement as part of the defining SELECT statement of the view.

Random Solutions  
 
programming4us programming4us