当我尝试以下查询
select column2
from table1
group by column2
having count(column3) = count(column1) and column5 in (1,2)
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
ORA-00979: not a GROUP BY expression
00979. 00000 - "not a GROUP BY expression"
Run Code Online (Sandbox Code Playgroud)
我应该写什么才能获得结果,即满足两个条件的column2
i.e. (count(column3) = count(column1) and column5 in (5,6).
试试这个:
select column2
from table1
where column5 in (1,2)
group by column2
having count(column3) = count(column1)
Run Code Online (Sandbox Code Playgroud)