oracle 报表带小计合计

select
case when (grouping(glbm)=1) then '合计' else DECODE(glbm,null,'',glbm) end glbm,
case when (grouping(hpzl)=1) then '' else DECODE(hpzl,null,'',hpzl) end hpzl,
case when (grouping(syxz)=1 and grouping(hpzl)=0) then '小计' else DECODE(syxz,null,'',syxz) end as syxz,
count(*)
from VEHICLEBA
where hpzl in ('01','02','15') and (ywlx='登记' or ywlx='转出中')
group by rollup(glbm,hpzl,syxz)

 

posted @ 2017-03-15 17:48  .NET_海  阅读(368)  评论(0编辑  收藏  举报