SELECT MAX( Salary) FROM Employee WHERE Salary < ( SELECT MAX( Salary) FROM Employee )
Coz max function is not on the first Salary after WHERE. The part after "<" is an independent table from the table "Employee WHERE Salary <....".
@qlan2 Having should be used after group by.
@qlan2 'HAVING' is used with 'Aggregate' function, for a further filter after GROUP BY usually. While 'WHERE' couldn't used with 'Aggregate' function compared with 'HAVNG'. This is my understanding ,though...
@qlan2 HAVING clause may only be used in conjunction with GROUP BY.
The resulting query will look like:
SELECT MAX(Salary) FROM Employee GROUP BY Salary HAVING SALARY != ( SELECT MAX( Salary) FROM Employee );
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.