GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Tech FAQs  >  SQL

 Print  |  
Question:  What is the Querry for retrieving the 2nd highest salary in a table?



March 03, 2006 23:47:45 #5
 satish   Member Since: Visitor    Total Comments: N/A 

RE: What is the Querry for retrieving the 2nd highest ...
 

SELECT MAX(E1.salary)  FROM ggg E1 , ggg E2
WHERE E1.salary< E2.salary

2.select top 1 salary  from ggg where salary<(select max(salary) from ggg)
order by  salary  desc

3.name   salary
rahul   15000
ronak   20000
saumil  25000

create table ggg (name varchar(20),salary int)

insert into ggg values ('saumil',25000)

select * from ggg

Select MAX(Salary) from ggg
Select MAX(Salary) from ggg where Salary <> (Select MAX(Salary) from ggg)

select top 1 salary  from ggg where salary<(select max(salary) from ggg)
order by  salary  desc

SELECT MAX(E1.salary)  FROM ggg E1 , ggg E2
WHERE E1.salary< E2.salary

     

 

Back To Question