A
A
AlexTym2017-04-19 10:43:49
MySQL
AlexTym, 2017-04-19 10:43:49

An error is thrown while executing the request. What is the problem?

Select employees who receive the highest salary for their work experience (experience - accurate to the nearest year).

SELECT last_name,YEAR(hire_date) AS [Year]
From employee
WHERE YEAR(hire_date) IN (
SELECT MAX(salary), YEAR(hire_date) AS [Year]                 
FROM employee
GROUP BY  YEAR(hire_date)                                  
)
GROUP BY  last_name, YEAR(hire_date)

At the same time, the request
SELECT MAX(salary), YEAR(hire_date) AS [Year]                 
FROM employee
GROUP BY  YEAR(hire_date)

performed correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-stream, 2017-04-19
@AlexTym

And what happens?
WHERE YEAR(hire_date) IN (
SELECT MAX(salary), YEAR(hire_date)
nested select will return TWO columns, and how can SQL deal with that?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question