
oracle查询一个字段的两种不同状态分别的合计
1个回答
展开全部
select sum(case when col = 'A' then 1 else 0 end ) a_count,
sum(case when col = 'B' then 1 else 0 end ) b_count
from xxx
更多追问追答
追问
不是查个数,要sum
追答
需求呢?应该会涉及到另外一列吧?
select sum(case when col = 'A' then num else 0 end ) a_sum,
sum(case when col = 'B' then num else 0 end ) b_sum
from xxx
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询