Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
with Groupedsalary(DepartmentId , totalEmp)
as
(
        select DepartmentId , SUM(salary) as Tsalary
        from tblEmployee group by DepartmentId


)


i am getting below error after typing above state ment.

Incorrect syntax near ')'.
Posted
Comments
Prasad Khandekar 8-Apr-14 8:10am    
with Groupedsalary(DepartmentId , totalEmp) as
(
select DepartmentId , SUM(salary) as totalEmp
from tblEmployee group by DepartmentId
)

SELECT DepartmentId , totalEmp FROM Groupedsalary
Andrius Leonavicius 8-Apr-14 8:25am    
Post it as a solution. ;)

Cte table requires select of table after its declaration.
lang="sql">with Groupedsalary(DepartmentId , totalEmp)
as
(
        select DepartmentId , SUM(salary) as Tsalary
        from tblEmployee group by DepartmentId


)
select * from Groupedsalary
 
Share this answer
 
Hi,
SQL
; with Groupedsalary as
(
        select DepartmentId , SUM(salary) as Tsalary
        from tblEmployee group by DepartmentId
)
select * from Groupedsalary

Happy Coding!
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900