var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: CTE in sql server 2008
Hello every body,
I have been facing this problem since long. I have a table student and I am defining a CTE on that using SQl server 2008 with following code:
(select ID,name,fees from student where fees>5000 group by ID)
and it gives me followig error "Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ')'."
. I dont see any apparant reason behind it . may be some body can help.
You can't just end a CTE definition with that, you need to do some processing on the result.
The error is telling you that it is expecting more code after your closing bracket...
(select ID,name,fees from student where fees>5000 group by ID,name,fees)
select * from cte_student
That really worked for me
Which really begs the question - why are you using a CTE in this scenario?
furthermore, your original query does have a syntaxt error - any columns not included in your GROUP BY definition must be aggregated (e.g. Sum, Max, Count).
SELECT id As cte_id
, name As cte_name
, fees As cre_fees
FROM student As cte
WHERE fees > 5000
Actually I am new to SQL server and I was learning CTE. I wrote a sample code which did not run properly so I posted the question on the forum. But yes I really got my answers thank you very much guys.