I would like to pivot table a sum of sales in SQL Server.
My table is slightly more complicated than what is below, but this is a good example:
The Pivot I am after should look something like this:
Obviously this is quite straightforward using MS Excel, however, since my data is ridiculously huge, it is housed at a table in SQL Server. Therefore, I am needing write an query to pivot table as example above.
What I have written is:
SELECT DISTINCT [Day] FROM [TABLE]
PIVOT (SUM(Cost) FOR [Prod] IN([Coke], [Pepsi], [Tango])) AS PIVOTSALES
However, I am failing to get the required result. Any advise how to proceed would be greatly appreciated.