Back to Practice
#0326
Departments With High Average Salary
EasySQL15 min10 XP
Problem
Return department and avg_salary for departments with average salary above 70000.
Why This Matters
SQL interviews usually test whether you can turn a business question into the right rows, grouping level, join type, and edge-case behavior.
Schema
employees(employee_id INTEGER, department TEXT, salary INTEGER)
Examples
Example 1
InputEng average is 80000, Ops is 60000
OutputEng only
HAVING filters after department averages are calculated.
Constraints
- Return only the requested columns.
- Use deterministic ORDER BY when multiple rows are returned.
- Assume SQLite-compatible SQL unless the prompt states otherwise.
CodeSQL
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core SQL case
InputEng average is 80000, Ops is 60000
Expected[["Eng",80000]]
HAVING filters after department averages are calculated.
Hidden Test Categories
Empty or missing matchesDuplicate rows or tiesNULL values where the pattern commonly breaks