Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to pivot using pivot clause of sqlserver 2005 for three values

$
0
0

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




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>