This question evaluates proficiency in relational data manipulation, including multi-table joins, grouping and aggregation to identify departments with multiple employees and top earners, tie-aware per-group selection, and filtering joined contact data.
You are given three tables:
company
employee_id
INT
first_name
VARCHAR
last_name
VARCHAR
department
VARCHAR
salary
DECIMAL
employee_contact
employee_id
INT
email
VARCHAR
phone_number
VARCHAR
years_at_company
INT
employee_social
employee_id
INT
linkedin
VARCHAR
employee_id is the key used to join the tables. There are no date or timestamp columns in this problem, so no time-window or timezone assumptions are needed.
Write SQL for the following progressive tasks:
department
department, employee_id, first_name, last_name, salary
department, employee_id, first_name, last_name, salary, email, phone_number, years_at_company
Note: The employee_social table is provided as part of the schema, but it is not required for these three tasks.