Link to home
Start Free TrialLog in
Avatar of haidershahzaib
haidershahzaib

asked on

Find Specific Record

Hello,
1: I have a table of following fields.
code    name      basic_salary
I want to to right a query or view which shows the second of  highest basic salary. etc.
code    name     basic_salary
1         abc          12000
2         xyz          12000
3         ehd         11000

so i want 11000(Basic Salary) figure
Note: i did not know about highest salary.
becuase i know the method show salary < 12000.
but i write a blind query which can execute every where.(not perfectly knowing the highiest salary.

Thanks.
Haider.

ASKER CERTIFIED SOLUTION
Avatar of Lori99
Lori99

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of acampoma
acampoma

oops, try this


select * from Salary_Table
where Basic_Salary=
(select min(Basic_Salary)
      from (select top 2  Basic_Salary from Salary_Table order by Basic_Salary desc)a)