I need help in simplifying the below query.
I was able to check for ‘0’ count without using Group By/having Count clauses in the below query but with correlated subquery.
Now, I’ve been asked to simplify the below query as simple joins!.
I tried merging the query into one. But the output differs.
Could you please suggest any other idea of simplifying the query, which is checking for ‘0’ count.
select distinct tab1.col1
from tab1
where tab1.col2 = 'A'
And 0 = (select count(tab2.col1)
from tab2
where tab2.col2 = 'B'
and tab2.col1 = tab1.col1)
This sort of thing would normally be written as a NOT EXISTS
However you could also write