EmpID EmpName Dept. Salary Location Rating 201 Smith IT 75000 Chicago 4.5 202 Jane HR 60000 New York 4.7 203 Alice Finance 80000 San Francisco 4.8 204 Bob IT 76000 Denver 4.6 205 Sarah Marketing 68000 Seattle 4.9
From the above table 'EMPLOYEE', which query will retrieve employees with rating above 4.6?
| EmpID | EmpName | Dept. | Salary | Location | Rating |
|---|---|---|---|---|---|
| 201 | Smith | IT | 75000 | Chicago | 4.5 |
| 202 | Jane | HR | 60000 | New York | 4.7 |
| 203 | Alice | Finance | 80000 | San Francisco | 4.8 |
| 204 | Bob | IT | 76000 | Denver | 4.6 |
| 205 | Sarah | Marketing | 68000 | Seattle | 4.9 |
From the above table 'EMPLOYEE', which query will retrieve employees with rating above 4.6?
Solution
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).
Related questions:
2025: 30 May Shift 2
2026: 18 May Shift 2
2025: 27 May Shift 2
2026: 29 May Shift 1
2025: 14 May Shift 1
2026: 21 May Shift 1