I have two tables. The first one is T_EMPLOYEE
create table t_employee
(
f_id number(8, 2) not null primary key,
f_name varchar(200),
);
The second is 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;
I want to get max salary and the name of the corresponding employee, I wrote this query
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;
but the result looks like this:
Jenny 5000
Andy 3000
Mary 1000
But I want to retrive only one name of the user who have the highest salary, so what am I doing wrong?