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.
Author |
Topic |
archana23
Yak Posting Veteran
89 Posts |
Posted - 2012-10-03 : 14:44:35
|
Hello,I am using this query SELECT *FROM(SELECT InvDate, Location, Inv+obs as TotalFROM InvInfo where (InvDate >= '8/1/2012')and (InvDate <= '8/31/2012') Group by InvDate ,Location ) dPIVOT(SUM (Total)FOR Location in ( [Dallas', [Atlanta], [Houston], [Raleigh], [Chicago] )) pBy using above query getting this resultsDate Dallas Atlanta Houston Raleigh Chicago 1 100 50 80 75 1202 80 60 77 82 110But In above results i want one more extra column(OBS) , thats gives my Actual results as shown belowHere is the Expecting ResultsDate Dallas Atlanta Houston Raleigh Chicago OBS1 100 50 80 75 120 202 80 60 77 82 110 18This extra columns will get by below queryselect sum(OBS) as OBS from InvInfo where (InvDate >= '8/1/2012')and (InvDate <= '8/31/2012') Group by InvDateSo how to combine these two queries to get Actual results as shown above.Please anyone Can help me on this?ThanksArchanaArchana |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|