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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to pivot using pivot clause of sqlserver 2005

Author  Topic 

rajemessage
Starting Member

17 Posts

Posted - 2014-01-09 : 02:17:04
Dear all

Is it possible to formulate the query using pivote clause of sqlserver 2005.

( Table name is) BridgeHawra

--------

ReportDate, , Pole, DiameterCost,Flag,OuterDiaCost

01 jan 2014, ,1 , 4.5 ,yes,6

01 jan 2014, ,2 , 4.5 ,no,6

01 jan 2014, ,3 , 5.5 ,no,6

02 jan 2014, ,4 , 5.5 ,no,5.9

02 jan 2014, ,5 , 5.5 ,no,6

1)Pole Col will have unique value.

o2)One pole will have one DiameterCost, but n number of DiameterCost can be there.

I have to show a report which should show , count of poles and cost(DiameterCost* pole count of the day of each DiameterCost) for each date and DiameterCost.

as following


DateOfReport , PoleCountofDiameterCost4.5, DiameterCost4.5, PoleCountOfDiameterCost5.5,DiameterCost5.5

01 jan 2014 , 2 ,(2*4.5) ,1 ,(1*5.5)

02 jan 2014 , 0/null ,0/null ,2 ,(2*5.5)


yours sincerely





visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-01-09 : 05:15:33
Answered here
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/6b73d712-63ad-4a3e-8315-618343c794e7/how-to-pivot-using-pivot-clause-of-sqlserver-2005-for-three-values?forum=transactsql

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -