'Create Pivot query in SQL Server like Excel pivot table
I am trying to convert an Excel pivot to a SQL query so instead of extracting the data first from my SQL Server database then create the pivot table manually in Excel, I want to create the pivot query directly in SQL.
Here is an example of my data and pivot table
I am stuck how to finish my SQL query, my start was :
SELECT [Brand],[Location],[Qty],[Price] FROM ShipmentsTable
PIVOT
(
SUM(Qty),SUM([Price])
FOR [MFG Location] IN ... --not sure what to add here
)
Any suggestions please how should I update my query ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
