Sobes.tech
Junior — Senior

SQL queries to find the employee with the highest salary and select departments with high average pay

livecode

Task condition

The database has the following schema:

// Table Departments
create table D (
    Id int primary key,
    Name nvarchar(100)
)

// Table Employees
create table E (
    Id int primary key,
    DepartmentId int foreign key references Departments(Id),
    Name nvarchar(100),
    Salary float
)

Two queries are required:

  1. Display the name of the employee with the highest salary in the company, along with the name of their department.
  2. Generate a list of departments where the average salary exceeds $1000.

Both queries should use only standard SQL features (JOIN, aggregate functions, ORDER BY, LIMIT/TOP, etc.).