How do I make this code work so that the min that gets typed in will be the same experience we will get from the query

Viewed 26
create table employee(
employ_id int (11),employee_name varchar(30),exp_in_months int(20),monthly_salary float );

insert into employee values ('1','manjesh','30', '11000');
insert into employee values ('2','raj','10', '5000');
insert into employee values ('3','johny','15', '8000');
insert into employee values ('4','joy','12', '7000');
insert into employee values ('11','pooja','10', '46000');
insert into employee values ('20','radha','40', '46000');
insert into employee values ('5','kirthi','10', '6500');

we can see that raj, pooja, kirthi have(10)years minimum & same experience so we have to find the monthlysalary of these three only.

or the question is

the total salary recieved by the junior most employee of the organization ,if more than one employee has the same experince then print the result in the order of input.....

I have tried this only

Select MIN( monthlySalary) as Salary 
from Employee 
order by monthlysalary desc;
1 Answers

Use a subquery to get the minimum experience, and use that to filter the employees.

SELECT employee_name, monthly_salary
FROM employee
WHERE exp_in_months = (SELECT MIN(exp_in_months) FROM employee)
ORDER BY monthly_salary DESC
Related