我正在尝试编写一个我认为是相当简单的查询,但事实证明比我想象的要难。我想将两个select语句的结果分开:
Select count (*) from tableA where columnA = 'A'
/
Select count (*) from tableA where columnA in ('1','2')我正在使用Oracle SQL Developer
感谢您的指导
发布于 2019-02-17 05:12:55
我建议使用条件聚合。。。但是使用sum()而不是count()
Select (sum(case when columnA = 'A' then 1 else 0 end) /
sum(case when columnA in ('1', '2') then 1 end)
)
from tableA;请注意,分母中缺少else。这将处理被零除的情况。
https://stackoverflow.com/questions/54726896
复制相似问题