Combination of CROSS APPLY
and PIVOT
should do:
select *
from (
select t.appname, x.status, x.val
from your_table t
cross apply (
values
('Total', t.total),
('Pending', t.pending),
('New', t.New),
('Approved', t.Approved),
('Rejected', t.Rejected)
) x (status, val)
) t pivot (
sum(val)
for appname in (
[GIN],[APINV],....
)
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.