3,491
社区成员
发帖
与我相关
我的任务
分享
select a.DCRQ,sum(decode(b.qhmc,'登封县',a.bl1)) 登封县,
sum(decode(b.qhmc,'孟县',a.bl1)) 孟县,
sum(decode(b.qhmc,'孟津县',a.bl1)) 孟津县
from XM_YS_YCXTDC_D a,sys_xzqhb b
where a.sxbm in ('410201','410301','410102') and
b.qhbm=a.sxbm and DCRQ >= TIMESTAMP '2006-08-01 00:00:00' and
DCRQ <= TIMESTAMP '2009-08-09 23:59:59'
group by a.dcrq
order by a.dcrq
SQL> select dcrq , to_char(max(case when qhmc = '登封县' then bl1 else 0 end), '99.99') as "登封县",
2 to_char(max(case when qhmc = '孟县 ' then bl1 else 0 end), '99.99') as "孟县",
3 to_char(max(case when qhmc = '孟津县' then bl1 else 0 end), '99.99') as "孟津县"
4 from test
5 group by dcrq
6 order by dcrq;
DCRQ 登封县 孟县 孟津县
-------------------- ------ ------ ------
2009-06-05 8.00 20.00 25.00
2009-06-10 14.00 22.00 35.00
2009-06-15 20.00 23.00 40.00