SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to pivot using pivot clause of sqlserver 2005
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rajemessage
Starting Member

17 Posts

Posted - 01/09/2014 :  02:17:04  Show Profile  Reply with Quote
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

India
52309 Posts

Posted - 01/09/2014 :  05:15:33  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000