SQL Developer Show the department id, department name and the number of employee
ID: 3810660 • Letter: S
Question
SQL Developer
Show the department id, department name and the number of employees working in any department which has less than 4 employees
Oracle SQL Developer File Edit View N Connections Columns Data TMC COUNTRIES Act CUSTOMER COLUMN DEPARTMENTS 1 EMPLOYEE DEPARTMENT ID 2 FIRST NAN E DEPARTMENT NAME 3 LAST NAM MANAGER ID LOCATION ID 4 EMAIL DOCNO 5 PHONE NU EMPLOYEES 6 HIRE DAT EMPLOYEE ID 7 JOB ID FIRST NAME 8 SALARY LAST NAME 9 COMMISSI EMAIL 10 MANAGER PHONE NUMBER HIRE DATE 11 DEPARTMEI E JOB ID EE SALARY COMMISSION PCT MANAGER ID DEPARTMENT ID INVENTORY IEEE ITEM ReportsExplanation / Answer
SELECT D.DEPARTMENT_ID, D.DEPARTMENT_NAME, count(E.EMPLOYEE_ID) as total
FROM DEPARTMENTS as D JOIN EMPLOYEES as E
ON D.DEPARTMENT_ID=E.DEPARTMENT_ID
GROUP BY D.DEPARTMENT_NAME
HAVING total<4;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.