This question is from HackerRank (Top Earners).
I wonder why
SELECT MAX(months * salary),
COUNT(*)
FROM Employee
WHERE (months * salary)
= MAX(months * salary)
this query doesn't work, but
SELECT MAX(months * salary),
COUNT(*)
FROM Employee
WHERE (months * salary)
= (SELECT MAX(months * salary) FROM Employee)
this query works.
Could you guys explain the reason?
Thanks.
I am trying to understand the operation logic of SQL.