Answer the question
In order to leave comments, you need to log in
How to add data in a sample?
There is a table with salaries SALARY(id, date, spec_id, value) and a table with company specialists SPECIALIST (id, name, specialty).
How to display the name of a specialist, specialty and total salary for 2017 BUT only for those whose salary for 2017 is more than 5000 rubles?
SELECT sp.name, sp.speciality, SUM(sa.value) AS val
FROM salary sa
INNER JOIN specialist sp ON sa.spec_id = sp.id
WHERE EXTRACT(YEAR FROM sa.date) = 2017
GROUP BY sp.id
HAVING SUM(sa.value) > 5000
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question