#412 Minimum and Maximum Salary by Unit

Companies:
Yandex
Themes:
SQLAggregationPractice

The database contains two tables: "units" for company units and "employees" for company employees:

Java
units:
    id      // Primary Key
    name    // unit name

employees:
    id      // Primary Key
    unit_id // Foreign Key -> units::id
    salary  // salary
    fired   // dismissed flag

Write an SQL query that returns the minimum and maximum salary for every unit among employees who have not been dismissed: unit_id, min_salary, max_salary.

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in