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 2008 Forums
 Transact-SQL (2008)
 sub total

Author  Topic 

papershop
Starting Member

27 Posts

Posted - 2011-08-15 : 03:06:28
Dear all

i have a pivot table like this

select line, familyname, isnull([1],0) as Jan ,isnull([2],0) as Feb ,isnull([3],0) as Mar,isnull([1],0)+isnull([2],0)+isnull([3],0) as Q1, isnull([4],0) as Apr, isnull([5],0) as Mei, isnull([6],0) as Jun, isnull([4],0)+isnull([5],0)+isnull([6],0) as Q2,
isnull([7],0) as Jul,isnull(,0) as Aug,isnull([9],0) as Sep,isnull([7],0)+isnull(,0)+isnull([9],0) as Q3, isnull([10],0) as Okt, isnull([11],0) as Nov, isnull([12],0) as Dec, isnull([10],0)+isnull([11],0)+isnull([12],0) as Q4
from (
select line, _month, familyname, valuenet from dbo.v_fact_sales
WHERE (_Year = @year))up
pivot (sum(valuenet) for _month in ([1],[2],[3],[4],[5],[6],[7],,[9],[10],[11],[12]) )as pvt
order by line


and the data that shows are like this

code product jan feb mar
AI LAS 100 50 25
AI CEF 75 25 25
AI CLA 25 255 252
C1 APR 458 255 366
C1 IRV 114 5144 411


what should i do if i want to add a sub total in that data? show the data wouldbe like this :

code product jan feb mar
AI LAS 100 50 25
AI CEF 75 25 25
AI CLA 25 255 252
sub total 200 330 302
C1 APR 458 255 366
C1 IRV 114 5144 411
sub total 572 5399 777


help me please

@papershop

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-08-15 : 03:25:08
the sub total line should be handle in your front end application


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -