|
archana23
Starting Member
37 Posts |
Posted - 10/03/2012 : 14:44:35
|
Hello,
I am using this query
SELECT * FROM ( SELECT InvDate, Location, Inv+obs as Total FROM InvInfo where (InvDate >= '8/1/2012') and (InvDate <= '8/31/2012') Group by InvDate ,Location ) d PIVOT ( SUM (Total) FOR Location in ( [Dallas', [Atlanta], [Houston], [Raleigh], [Chicago] ) ) p
By using above query getting this results
Date Dallas Atlanta Houston Raleigh Chicago 1 100 50 80 75 120 2 80 60 77 82 110
But In above results i want one more extra column(OBS) , thats gives my Actual results as shown below
Here is the Expecting Results
Date Dallas Atlanta Houston Raleigh Chicago OBS 1 100 50 80 75 120 20 2 80 60 77 82 110 18
This extra columns will get by below query
select sum(OBS) as OBS from InvInfo where (InvDate >= '8/1/2012') and (InvDate <= '8/31/2012') Group by InvDate
So how to combine these two queries to get Actual results as shown above.
Please anyone Can help me on this?
Thanks
Archana
Archana |
|