Select dept from emp group by dept having count(*)<2;
Select name from emp where dept=(select dept from emp group by dept having count(*)<2);
Why we used subquery in 2nd query and not in 1st?
can we also write 2nd query like this
Select name from emp group by dept having count(*)<2;
I am not able to understand when to use subquery or when not.
New contributor
Ankit Singh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1