So I am doing some work and I have a question where I'm having some trouble conceptually understanding how to do this query. I have a table of Employees which has their name, pay and department. I want to get the number of members in each department, so I did the subquery to get all the departments and by using the DISTINCT keyword I have no repeats, however, when I try to use that as a match phrase, select * from Employees where Department=(select distinct Department from Employees); it only matches the first value of the table of departments and when I use the IN keyword it doesn't group them (as all the depts are in the subquery), so I can't count them later as it will be all employees. So how do I properly form the query for it to iterate all the values of the subquery.
Aucun commentaire:
Enregistrer un commentaire