can anybody tell us, how to select 2nd max salary from
table.
my id is ashish.akk@gmail.com
Answers were Sorted based on User's Feedback
Answer / harikumar
select max(salary) as secondMax from employee where salary
<> (select max(salary) from employee)
| Is This Answer Correct ? | 1 Yes | 0 No |
select max(salary)from tablename where salary <(select
max(salary)from tablename)
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / darshan shah
select top 1 * from (select top 2 * from emp order by sal
desc ) a order by sal asc
Plz try this.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / govind.konduri
hai..
select sal from emp where sal=(select max(sal) from
emp where sal<(select max(sal) from emp))
->here,the sub inner query finds the max sal from emp table.
->the main inner query find out the max sal that is less
than the sub inner query max sal.
->the sub query result is sent to outer query..
| Is This Answer Correct ? | 2 Yes | 1 No |
hi,
my id is ravi106109@gmail.com
select sal from emp a
where 1=(select count(b.sal) from emp b
where a.sal<b.sal) order by sal desc;
and also dileep is write
| Is This Answer Correct ? | 3 Yes | 3 No |
Answer / dhaval
we have to use distinct key word there is a possibility
that two person having same salary.
select top 1 sry from (select distinct top 2 sry from emp
order by sry desc)t1 order by sry asc
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / kavitha.r
This query is generalised query if u replace 2 by 100 ,
then you will get 100th max salary
select top 1 salary from employee where salary in( select
top 2 salary from employee order by salary desc) order by
salary asc
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / kumar amit ranjan
To find Top 3 max Sal.... to put any number on the place of
3 to find nth max sal...
select top 3 sal from emp order by sal desc
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / naufal basheer
select e.* from
(select row_number() over (order by salary desc) as Rno,*
from employee)e
where e.Rno = 2
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / mahesh
Select max(sal) from emp
where id='1233' and Sal< (select max(sal) from emp)
| Is This Answer Correct ? | 1 Yes | 1 No |
What is a Lock and let me know Different types of locks?
Explain sql delete command?
What is sql server 2000 work load governor?
what's the difference between SQL & MY-SQl...? And what we learn from these ....?
How the authentication mode can be changed?
Is it possible we can connect our SQL database to GUI application? If it is yes than how tell me the explanation
How to delete duplicate rows?
What is reference section?
Wht is the difference between stored procedure and trigger
Tell me the difference between clustered and non-clustered index?
what is the Surrogate key?and wt is the diff between Primary key and Surrogate Key?
Name the different type of indexes in sql?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)