Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi Khtan,Great code. having question about how to make it order by c.name?I am also doing this pivot functionality and wondering is it possible to add the order by clause.thanks
sqllover
Constraint Violating Yak Guru
338 Posts
Posted - 2014-03-03 : 16:05:22
This is how i achieved. am all set
SELECT *FROM(SELECT c.id_customer,c.name,pr.price_name,pr.price_valueFROM customer cINNER JOIN prices prON pr.id_customer = c.id_customer)tPIVOT (SUM(price_value) FOR price_name IN ([D1],[D2]))porder by p.name