Професионална програма
Loading...
Spaskich avatar Spaskich 36 Точки

[Data Aggregation] Problem 18 - Salary Challenge

Здравейте, колеги!

Мъча се с последната задача от Data Aggregation упражнението. Ето това ми е кодът:

SELECT e.first_name, e.last_name, e.department_id
FROM employees AS e
WHERE e.salary > (
	SELECT AVG(inside.salary)
	FROM employees AS inside
	WHERE inside.department_id = e.department_id
	GROUP BY inside.department_id
)
ORDER BY e.department_id
LIMIT 10;

Ако някой може да ме насочи къде ми е грешката, ще съм му много благодарен! :)

0
Module: Java DB
dgp_82 avatar dgp_82 19 Точки

За SQL Това минава в Judge:

SELECT TOP 10  e.FirstName, e.LastName, e.DepartmentID
FROM Employees AS e
JOIN
(SELECT e.DepartmentID, avg(e.Salary) AS avgs
FROM Employees AS e
GROUP BY e.DepartmentID) AS avgSalaries
on e.DepartmentID = avgSalaries.DepartmentID
where e.Salary > avgSalaries.avgs
order by e.DepartmentID

0