Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with pivot/unpivot in traffic counts
Message
From
16/07/2014 13:24:56
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2014
Application:
Web
Miscellaneous
Thread ID:
01603833
Message ID:
01603846
Views:
45
>
>Try:
>
>;with cteUnpvt AS (SELECT * FROM
>   (SELECT classification, p1, p2, p3, p4, p5
>   FROM ClassCounts WHERE LocID='N-18') p
>UNPIVOT
>   (VehicleCount FOR [TimePeriod] IN 
>      (p1, p2, p3, p4, p5)
>)AS unpvt)
>
>select * FROM cteUnpvt PIVOT (max(VehicleCount) FOR Classification IN ([1],[2],[3],[4],[5],[6])) pvt
>
Great response
Previous
Reply
Map
View

Click here to load this message in the networking platform