Reputation: 31
How to display department name and number of employees working for that department.
My SQL code:
SELECT department.dname , employee.count(*)
FROM employee
INNER JOIN department
ON dno=dnumber
ORDER BY department.dname;
Upvotes: 0
Views: 247
Reputation: 1270733
The correct syntax is:
select d.dname, count(*)
from employee e inner join
department d
on d.dno = e.dnumber
group by d.dname
order by d.dname;
Notes:
GROUP BY
.dno
comes from. There should be no reason to guess.Upvotes: 1