Skip to main contentSkip to solution

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

From the above table 'EMPLOYEE', which query will retrieve employees with rating above 4.6?

Solution

✅ Correct Option: 1

WHERE filters individual rows, so WHERE Rating > 4.6 keeps only rows with a rating strictly above 4.6: Jane (4.7), Alice (4.8) and Sarah (4.9). Bob is left out because 4.6 is not greater than 4.6.


Option 2: GROUP BY merges rows into one per department, and EmpName is neither grouped nor aggregated, so the query is invalid in standard SQL.

Options 3 and 4: HAVING filters groups after aggregation, not individual rows. Rating is not a grouped or aggregated column, so these are misuses.

Use WHERE for row conditions and HAVING for conditions on aggregates such as COUNT(*) or AVG(Salary).

Keyboard Shortcuts

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