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
What are the types of database schema? : sql server analysis services, ssas
what's new in sql server 2016?
What do you understand by SQL*Net?
Call by value and call by reference in procedure and function, with NOCOPY.
if no size is defined while creating the database, what size will the database have? : Sql server administration
Retrieve the unique rows from table without using UNIQUE and DISTINCT keywords.
What is an expression in ms sql server?
how many clustered indexes can be created on a table? : Sql server database administration
How to create a testing table with test data in ms sql server?
If any stored procedure is encrypted, then can we see its definition in activity monitor?
How can change procedure in sql server?
How to defragment table indexes?
How many replicas are maintained for each sql azure db?
Explain filestream storage of sql server 2008?
What are the differences between left join and inner join in sql server?