Skip to main contentSkip to solution

EmpIDEmpNameDept.SalaryLocationRating
201SmithIT75000Chicago4.5
202JaneHR60000New York4.7
203AliceFinance80000San Francisco4.8
204BobIT76000Denver4.6
205SarahMarketing68000Seattle4.9

Based on the table 'EMPLOYEES' above, what will be the correct sequence of the following statements that will provide the total number of employees in each dept?

(A) SELECT column Dept

(B) GROUP BY Dept

(C) COUNT(*) the total number of employees

(D) FROM the table EMPLOYEES

Solution

✅ Correct Option: 2

The query that gives the number of employees in each department is:

SELECT Dept, COUNT(*) FROM EMPLOYEES GROUP BY Dept;\text{SELECT Dept, COUNT(*) FROM EMPLOYEES GROUP BY Dept;}

The clauses must appear in the order SELECT, FROM, GROUP BY, so the statements go in this order:

(A) SELECT column Dept

(C) COUNT(*) the total number of employees (part of the SELECT list)

(D) FROM the table EMPLOYEES

(B) GROUP BY Dept


Option 1: GROUP BY cannot come before FROM, because the table must be named before its rows are grouped.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question