Computer Science
Schemas of tables EMPL, Dept, SalaryGrade are being shown below :
EMPL (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
SALARYGRADE (Lowsal, Highsal, Grade)
DEPT (Deptno, DeptName, Location)
List the department names and the number of their employees.
SQL Joins & Grouping
2 Likes
Answer
SELECT d.DeptName AS Department_Name, COUNT(e.EMPNO) AS Number_of_Employees
FROM DEPT d, EMPL e
WHERE d.Deptno = e.DEPTNO
GROUP BY d.DeptName;
Answered By
3 Likes
Related Questions
Below are the customer and order tables :
Customers
customer id (PK) first_name last_name email address city state zip Orders
order id (PK) order_date amount customer_id (FK) List the total of customers' orders grouped by customer (id).
Below are the customer and order tables :
Customers
customer id (PK) first_name last_name email address city state zip Orders
order id (PK) order_date amount customer_id (FK) List the sum of the totals of orders grouped by customer and state.
Below are the customer and order tables :
Customers
customer id (PK) first_name last_name email address city state zip Orders
order id (PK) order_date amount customer_id (FK) List the customers (name) and the total amount of all their orders.
Schemas of tables EMPL, Dept, SalaryGrade are being shown below :
EMPL (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) SALARYGRADE (Lowsal, Highsal, Grade) DEPT (Deptno, DeptName, Location)
List the employee names and the name of their departments.