#187 Queries for Employees and Payments

Companies:
Itone
Themes:
SQLJoinsAggregationPractice

There are two tables:

Persons containing the list of employees

id | name
----------
1  | Petya
2  | Vasya
3  | Kolya

Payments containing monthly salary accruals

id | person_id | amount
-----------------------
1  | 1         | 10
2  | 1         | 20
3  | 3         | 15

The tables have a one-to-many relationship. An employee may have several payments or no payments at all if they have just joined the company. It is necessary to:

  • Select all employees together with their salary accruals.
  • Select employees whose total accrual amount exceeds 25.

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