我有两张桌子。第一个是 T_EMPLOYEE
create table t_employee
(
f_id number(8, 2) not null primary key,
f_name varchar(200),
);
第二个是 T_SALARY
create table t_salary
(
f_id number(8, 2) not null primary key,
f_employee_id number(8,2),
f_salary number(8, 2)
);
ALTER TABLE t_salary ADD CONSTRAINT fk_salary
FOREIGN KEY (f_employee_id) REFERENCES t_employee;
我想获得最高工资和相应员工的姓名,我写了这个查询
select t_employee.f_name, MAX(f_salary)
from t_salary
inner join t_employee on t_salary.f_employee_id=t_employee.f_id
group by f_name;
但结果如下所示:
Jenny 5000
Andy 3000
Mary 1000
但是我只想检索薪水最高的用户的一个名字,那我做错了什么?