I found this example on https://sqlbolt.com/topic/subqueries
Isn't the "dept_employees" on the last row of the query should refer to a table? From the row before it shows that it is a column.
I have tried to run it on MySQL and got "Error Code: 1054. Unknown column 'dept_employees.department' in 'where clause'"
Perhaps it could be simplified to this but I do not know anything about MySQL.
SELECT * FROM employees WHERE salary > ( SELECT AVG(revenue_generated) FROM employees WHERE department = employees.department )
2.1m questions
2.1m answers
60 comments
57.0k users