我有一个表名“员工”,我需要获取薪水最大值的行以及员工来自“纽约”的位置。
select * from employee where city = 'New York' and MAX(salary);
好像不行,求指教
我有一个表名“员工”,我需要获取薪水最大值的行以及员工来自“纽约”的位置。
select * from employee where city = 'New York' and MAX(salary);
好像不行,求指教
尝试这个::
select
*
from employee
where city = 'New York'
order by Salary desc limit 1
这是简单的方法。您也可以使用 group by then 子查询
select * from employee where city = 'New York' order by Salary desc limit 1
像这样,您将获得所有来自纽约的薪水最高的员工。IE 如果你有另一个员工salary = 2000
,你也会得到它。
SELECT * FROM employee WHERE city = 'New York' AND salary = MAX(salary);