June 4, 2009 at 6:26 pm
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:
with cte_student(cte_ID,cte_name,cte_fees)
AS
(select ID,name,fees from student where fees>5000 group by ID)
and it gives me followig error. I dont see any apparant reason behind it . may be some body can help.
Kunaal
June 4, 2009 at 7:15 pm
What error? You didn't post the error.
June 4, 2009 at 7:38 pm
Oh yah I am sorry the error is " Msg 102, Level 15, State 1, Line 4
Incorrect syntax near ')'."
Kunal 🙂
June 4, 2009 at 8:45 pm
Well, you actually have several problems. One, no select, insert, update, or delete using the CTE. Second, you have a group by query in the CTE with no aggregates.
As an example, without correcting the second problem, you need something like this:
with cte_student(cte_ID,cte_name,cte_fees)
AS
(select
ID,
name,
fees
from
student
where
fees > 5000
group by
ID)
select
*
from
cte_student;
June 5, 2009 at 4:08 am
Thank you very much that worked for me...
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply