我正在尝试对列进行垂直和水平总计,请参阅以下查询,我能够进行垂直总计。
Select
U_POD 'City',
Sum([Customer TS Pending]) as CTST ,
sum([Pending])as P,
sum([Pending SQ])as 'PSQ',
sum([Tracking])as Tracking,
SUM([Open])as Openn
from
(
Select T1.U_POD,T2.Name
from OSCL T0
inner join OCRD T1
on T0.Customer=T1.cardcode
inner join OSCS T2
on T2.statusID=T0.Status
)Service
Pivot
(
count(Name)
for Name IN ([Pending],[Pending SQ],[Tracking],[Open],[Customer TS Pending])
)pvt
group by rollup (pvt.U_POD)