Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I get this error when I use Pivot operator

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '('.

SQL
CREATE TABLE BookSalesTable
(BookType VARCHAR(20), SalesYear INT, BookSales Int);




SQL
SELECT *
FROM BookSalesTable
  PIVOT (SUM(BookSales)
  FOR SalesYear IN([2013], [2014])
  ) AS PivotSales;



Can any one please help
Posted
Comments
Abhipal Singh 14-Jun-15 0:53am    
The code you posted looks fine.. Can you tell on which '(' the error is thrown in your query?

1 solution

Perfectly works for me. See the SQLFiddle - http://sqlfiddle.com/#!3/b82c6/1/0[^].
 
Share this answer
 
Comments
Afzaal Ahmad Zeeshan 14-Jun-15 8:12am    
+5
Thanks Afzaal. :)

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