oracle中如何查询表中每一列中值为N的个数?

2025-04-26 09:54:48
推荐回答(3个)
回答1:

select sum(case when 字段A='1' then 1 else 0 end),sum(case when 字段B='1' then 1 else 0 end),sum(case when 字段C='1' then 1 else 0 end) from txt
注:'1'可以改为你需要的N

回答2:

使用公式 针对A列 ‘=COUNTIF(A1:A3,"1")’ 然后其他的列拉过去可以实现

回答3:

select sum(A),sum(B),sum(C) from txt