I am trying to write a sql query with grouping and I get the error:- Incorrect syntax near the keyword ‘with’.
The query I am writing is as below:-
SELECT CONTRACT,
PACONTNUMBER,
Project Manager ID,
Status,
Project Type,
Project Fee Amount,
Forecast Total Cost,
Forecast Profit,
Forecast %,
Actual Billings,
Actual Total Cost,
Current Actual Profit,
Current %,
GROUPING(PACONTNUMBER) as PACONTNUMBER,
SUM(Project Fee Amount) as Project Fee,
SUM(Forecast Total Cost) as Forecast Cost,
SUM(Forecast Profit) as Forecast Profit,
SUM(Forecast %) as Forecast Percentage,
SUM(Actual Billings) as Billings Total Actual,
SUM(Actual Total Cost) as Total Cost Actual
FROM dbo.vwPAProjects_Summary_New_2
GROUP BY
CONTRACT,
Project Manager ID,
Status,
Project Type,
Project Fee Amount,
Forecast Total Cost,
Forecast Profit,
Forecast %,
Actual Billings,
Actual Total Cost,
Current Actual Profit,
Current %,
PACONTNUMBER with rollup
ORDER BY GROUPING (PACONTNUMBER)
Can anyone point me in the right direction in trying to get this to work?
Many thanks,
You cannot have spaces in your identifiers. For SQL Server you can surround then in square brakets
[x]for example: