select id ,yf 月份, sum(汇总) hz from biao
where to_char(yf) < to_char(?,'mm') and to_char(yf) >to_char(?,'mm')
group by id ,yf
select id, sum( case when yf=01 then hz else 0 end),
sum(case when yf=02 then hz else 0 end ) ,
.............
..............
from biao
2个?号代表客户输入的月份
现在需要行列转换下
编程下面的那个查询
但是这样case 吧12个月份都写死了
能不能过滤一下客户没有输入的月份?
或者有更好的写法的
只能用select 拜托了
where to_char(yf) < to_char(?,'mm') and to_char(yf) >to_char(?,'mm')
group by id ,yf
select id, sum( case when yf=01 then hz else 0 end),
sum(case when yf=02 then hz else 0 end ) ,
.............
..............
from biao
2个?号代表客户输入的月份
现在需要行列转换下
编程下面的那个查询
但是这样case 吧12个月份都写死了
能不能过滤一下客户没有输入的月份?
或者有更好的写法的
只能用select 拜托了
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货