Sobes.tech
Senior

Table person with a list of employees id name 1 Petya 2 Vasya 3 Kolya Table payment with salary accruals id person_id payment_value [phone] It is necessary to write a query to select the names of employees with total accruals greater than 100

sobes.tech AI

Answer from AI

To select employees whose total earnings exceed 100, you can use an SQL query with table joins and grouping by employee:

SELECT p.name
FROM person p
JOIN payment pay ON p.id = pay.person_id
GROUP BY p.id, p.name
HAVING SUM(pay.payment_value) > 100;

This query joins tables on person_id, groups by employee, and filters only those whose sum of payment_value exceeds 100.