我不知道你需要hour_id 的总数还是总和,下面用子查询可以求出hour_id 的和。
select sum(hour_id ) , count(hour_id ) from
(
select hour_id,
TICKET_FAMILY,
sum(case when hour_id in(10,11,12) then total_in else 0 end) as total_in,
sum(case when hour_id in(10,11,12) then total_out else 0 end) as total_out
from tmo_od_flow_stats_mg
where gathering_date between to_date('2015-01-05','yyyy-mm-dd') and to_date('2015-01-05','yyyy-mm-dd')
group by hour_id,
TICKET_FAMILY
) t
以上就是关于在数据库中怎么求出表的数据,并能求出每列的总和怎么用SQL实现呢全部的内容,包括:在数据库中怎么求出表的数据,并能求出每列的总和怎么用SQL实现呢、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)