Notice: Undefined index: HTTP_ACCEPT_ENCODING in C:\server\web\www.showyounger.com\s-system.php on line 2
oracle group by rollup | 小样儿(ShowYounger)
小样儿,顶呱呱!!![http://www.showyounger.com]
- select sum(a.dqh) as dqh, nvl(c.zdmc, '合计') as dqmc, sum(a.fsje) as ckje, sum(b.fsje) as jfje from
- (select dqh, sum(fsje) as fsje from
- (select b.dqh, a.fsje
- from table_test1 a, table_test2 b
- where
- a.hyzh = b.bzjzhbh
- and a.ywbz in ('1011','2000','1999')
- union all
- select zddm as dqh, 0 as fsje from xtgl_sjzd where zdlbdm = 'DQH')
- group by dqh) a,
- (select dqh, -sum(fsje) as fsje from
- (select b.dqh, a.fsje
- from table_test1 a, table_test2 b
- where
- a.hyzh = b.bzjzhbh
- and a.ywbz in ('1051','1052','1053')
- union all
- select zddm as dqh, 0 as fsje from xtgl_sjzd where zdlbdm = 'DQH')
- group by dqh) b,
- xtgl_sjzd c
- where a.dqh = b.dqh and a.dqh = c.zddm and c.zdlbdm = 'DQH'
- group by rollup(c.zdmc)
- order by dqh, decode(dqmc,'合计',9,1)