SQL I have two tables: Employee and Department Fields of Employee : id, name, dept_id Fields of Department: dept_id, name I need a query which fetches me department name and number of employees per department along with it, even if number of employees for a department is zero. I tried the query below, but it returns only those departments which have number of employees more than zero. select d.name, count(e.id) as
I have two tables: Employee and Department Fields of Employee : id, name, dept_id Fields of Department: dept_id, name I need a query which fetches me department name and number of employees per department along with it, even if number of employees for a department is zero. I tried the query below, but it returns only those departments which have number of employees more than zero. select d.name, count(e.id) as "Number of employees per department"
from department d, employee e
where d.DEPT_ID=e.DEPT_ID
group by d.name
order by count(e.id) desc; Please help
RELATED QUESTIONS
RELATED TOPICS
ABOUT ANSWERBAG
Answerbag wants to provide a service to people looking for answers and a good conversation. Ask away and we will do our best to answer or find someone who can.We try to vet our answers to get you the most acurate answers.
Copyright 2023, Wired Ivy, LLC