How to pivot a table with a text identifier and number value?
This is my table (services):
Street | Service | Total
---------|---------------|------
Street A | Service AA 01 | 20
Street A | Service AB 01 | 10
Street A | Service AB 01 | 15
Street A | Service AC 01 | 05
Street B | Service AA 01 | 10
Street B | Service AA 01 | 03
Street B | Service AB 01 | 05
Street B | Service AC 01 | 03
This is the result that I wanna:
Street | Service AA 01 | Service AB 01 | Service AC 01
---------|---------------|---------------|--------------
Street A | 20 | 25 | 05
Street B | 13 | 05 | 03
What I tried so far:
SELECT Street, ['SERVICE AA 01'], ['SERVICE AB 01'], ['SERVICE AC 01']
FROM services PIVOT (
SUM(Total) FOR Service IN (['SERVICE AA 01'], ['SERVICE AB 01'], ['SERVICE AC 01'])) AS D
Got the streets, all columns, but all values is always null;