Using the MIN function in the having clause

后端 未结 7 1082
感动是毒
感动是毒 2021-01-18 07:06

I want to get the name of the employee who has the minimum salary. Is there a way to do this using only one query? I have given my query below, it doesn\'t work because the

7条回答
  •  清歌不尽
    2021-01-18 07:49

    Try this solution, inspired from here:

    SELECT e1.first_name, e1.salary AS "sal"
    FROM Employees e1
    LEFT OUTER JOIN Employees e2
    ON (e1.id <> e2.id AND e1.salary > e2.salary)
    WHERE e2.id IS NULL;
    

提交回复
热议问题