Problem · Database
Employees Above Average Salary
Problem statement
The table employees stores one row per employee and their salary.
Compute the average salary across all rows. Return every employee whose salary is strictly greater than that overall average.
Return employee_id, employee_name, and salary. Order rows by salary descending, then employee_id ascending.
What the interview report shared
The interview report listed a SQL task about employees whose salary is greater than the average salary.
| Column | Meaning |
|---|---|
employee_id | Unique employee identifier |
employee_name | Employee display name |
salary | Employee salary |
Table schema
MySQLPostgreSQLPandas
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
employees
One row per employee.
| Column | Type | Nullable | Description |
|---|---|---|---|
| employee_idPK | Integer | No | — |
| employee_name | Text | No | — |
| salary | Integer | No | — |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| employee_id | Integer | No | — |
| employee_name | Text | No | — |
| salary | Integer | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- The
employeestable has between1and10^5rows. employee_idis unique and non-null.employee_nameandsalaryare non-null.0 <= salary <= 10^9.