how to find the second salary?
Answers were Sorted based on User's Feedback
Answer / amruta dash
select max(salary) from tblname where salary not in (select
max(salary) from tblname);
| Is This Answer Correct ? | 23 Yes | 1 No |
Answer / vamsi krishna
For 2nd maximum salary
select Max(sal) from EMP a where 2=(select COUNT(distinct(sal)) from EMP b where a.SAL<=b.SAL);
| Is This Answer Correct ? | 14 Yes | 3 No |
Answer / rajkumar v
Select min(salary)FROM emp WHERE (salary IN (SELECT TOP 2
salary FROM emp ORDER BY salary DESC))
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / kavitha
select max(salary) from tablename where salary not in(select
max(salary) from tablename )
or
select max(salary) from tablename where salary <(select
max(salary) from tablename )
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / vishnu
Here we can find out 2nd highest salary in many ways,
according to the situation we can select anyone…
1st Type:
select min(esal) from emp where esal in (select top 2 esal
from emp order by esal desc)
2nd Type:
select max(esal) from emp where esal not in(select max(esal)
from emp)
3rd Type:
select max(esal) from emp where esal <(select max(esal) from
emp )
4th Type:
select Max(esal) from EMP a where 2=(select
COUNT(distinct(esal)) from EMP b where a.eSAL<=b.eSAL);
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / m.s.patil
select max(sal) from t1 where sal not in (27777);
27777 is max salary in table
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / sannnnnnnnnnn
select max(sal) from emp where sal<(select max(sal) from emp)
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / raja
select top1 salary from(select distinct top2 salary from
table name order by salary desc)a order by salary
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / moorthy t
select n,* from(select rownum n,* from (select * from table
where group by (sal) order by (sal) desc)) where n=2;
| Is This Answer Correct ? | 0 Yes | 2 No |
select max(salary) from salary_table where salary in(select
top 2 salary from salary_table order by salary desc)
| Is This Answer Correct ? | 2 Yes | 5 No |
what is isolation level at dead lock?
What is abstracting periodical?
What is the difference between DataRow.Delete() and DataRow.Remove()?
How do database indexes work?
Explain what is dbcc?
IF more than one Site is accessing the same Database server and I want to move the DB with Minimum down time? How will you do
How can your resolve deadlocks?
4 Answers IBM, IMS, Iron Mountain, NuWare,
What are the options which must be set to allow the usage of optimistic models?
Define master database?
Explain the stored procedure?
How you can get a list of all the table constraints in a database?
how can you find out if the current user is a member of the specified microsoft® windows nt® group or microsoft sql server™ role? : Sql server administration
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)