How to find the second largest salary in the emp database and
also How to find 3rd,4th and so on ........ in the emp database

plz mail the answer @ mak2786@gmail.com

Answer Posted / punit kumar

1.To find second highest salary

select max(sal) from emp_record
where sal not in (select max(sal)from emp_record)


2.To find second highest salary

select max(sal) from emp_record
where sal < (select max(sal)from emp_record)


3.create table punit(rn varchar(30),salary int)
insert into punit values('a',10000)
insert into punit values('b',12000)
insert into punit values('c',15000)
insert into punit values('e',25000)
insert into punit values('d',22000)
insert into punit values('f',30000)
insert into punit values('h',35000)
insert into punit values('g',32000)
insert into punit values('i',32000)
select * from punit order by salary desc
Select * from punit a where 1=(select count(distinct b.salary)
from punit b where a.salary <=b.salary)
Select * from punit a where 2=(select count(distinct b.salary)
from punit b where a.salary <=b.salary)
Select * from punit a where 3=(select count(distinct b.salary)
from punit b where a.salary <=b.salary)
Select * from punit a where 4=(select count(distinct b.salary)
from punit b where a.salary <=b.salary)



by:-

PUNIT CHAUHAN

DELHI
MCA STUDENT STUDIS IN NOIDA

Is This Answer Correct ?    9 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the web service used for reporting services?

96


Is a null value equal to anything? Can a space in a column be considered a null value? Why or why not?

624


Does partitioning improve performance?

469


Explain DBCC?

558


Explain four layers of abstraction microsoft architectured?

120






What are the diifferences between the ms sql server vs mysql?

640


What new changes are being made in SQL Server?

565


What are approximate numeric data types in ms sql server?

578


What are different backups available in sql server?

594


Do you know how to make remote connection in database?

542


Explain different types of self contained sub query?

530


What is isolation levels?

557


What is the difference between ‘having’ clause and a ‘where’ clause?

531


What are horizontal and vertical scaling?

144


Explain the microsoft sql server delete command?

522