Can I check more than two conditions with an offer?
When I try the following request
select column2
from table1
group by column2
having count(column3) = count(column1) and column5 in (1,2)
I am getting this error:
ORA-00979: not a GROUP BY expression
00979. 00000 - "not a GROUP BY expression"
What should I write to get the result, i.e. column2 that satisfies both the conditions
i.e. (count(column3) = count(column1) and column5 in (5,6)
...
+3
source to share
3 answers
Actually, you have a part that should be where the condition is, not like below.
SELECT column2
FROM table1
WHERE column5 IN (1,2)
GROUP BY column2
HAVING COUNT(column3) = COUNT(column1)
Always use aggregate functions in a clause clause to perform validation in a query, not in a section.
+3
source to share
you use together and group by sentences. Everything is good.
But you can add where clause to your query below condition
column5 in (1,2)
Once you restructure your query like below and I hope you get your solution
select column2 where column5 in (1,2) -- here is your where condition
from table1
group by column2
having count(column3) = count(column1)
0
source to share