我需要为Oracle 11g编写一个查询,以便只选择图像中突出显示的组。具体来说,有3列- A、B和C列-A、B和C。

我只需要选择C列中不包含任何null值的行组--即组3行和组5行。我只需要组号,比如只返回一个3和一个5,我可以用什么SQL函数来编写这个查询?这个查询是什么样子的?
类似于(伪代码)
select colA, count(*) As cnt From tblX join to itself on something
Where ...something ... 
Group By colA(或者我们可以跳过分组,只选择3和5或3 3和3 5)。
发布于 2016-06-17 21:05:32
聚合函数COUNT(colname)将只计算非空值,因此类似的内容可能会工作:
select A from yourtable
group by A
having count(A) = count(C)假设A从未为空。
发布于 2016-06-17 20:51:50
可以使用not in子句和子查询。
select colA, count(*) As cnt 
From tblX 
Where colA not in (select distinct colA from tblx where colC is  null)
Group By colAhttps://stackoverflow.com/questions/37889666
复制相似问题