Write a query to get 2nd maximum salary in an employee table ?
Answers were Sorted based on User's Feedback
Answer / jebitha
select max(sal) from emp where sal<>(select max(sal) from
emp);
| Is This Answer Correct ? | 7 Yes | 9 No |
Answer / babbu
it's easy with self join:
select max(sal) from emp e1,emp e2 where e1.sal < e2.sal
| Is This Answer Correct ? | 0 Yes | 2 No |
Answer / lakshminarayana reddy
select rownum,empno,ename,job,sal from emp(select
rownum,empno,ename,job,sal from emp order by sal desc) grop
by rownum,empno,ename,job,sal having rownum=2;
| Is This Answer Correct ? | 7 Yes | 10 No |
Answer / varun
select max(sal) from emp ((select sal from emp)-(select max
(sal) from emp))
| Is This Answer Correct ? | 5 Yes | 8 No |
Answer / naresh kumar kalangi
select top 1 * from (select top 2 * from emp order by sal
desc)s order by sal
| Is This Answer Correct ? | 5 Yes | 8 No |
Answer / surajit pathak
select * from emp e1
where 2>(select count(1) from emp e2
where e2.sal>e1.sal)
order by sal desc
| Is This Answer Correct ? | 1 Yes | 4 No |
Answer / satya_k21
Hi,
Select * from emp e where 2>= (select count(sal) from
emp e where sal>=e.sal) order by desc.
Let me know if it is wrong..
Regards,
Satya.K
| Is This Answer Correct ? | 11 Yes | 16 No |
Answer / rajesh.m
Crete Table Curtest(Emp char(40),salary money)
------------------------------------------------
Select Min(Salary) from Curtest where Salary
in (select Top 2 Salary from Curtest)
--------------------------------------------------
| Is This Answer Correct ? | 21 Yes | 33 No |
Answer / varun
select sal from emp where rownum=2 order by sal desc;
| Is This Answer Correct ? | 6 Yes | 19 No |
what is the different between now() and current_date()? : Sql dba
how to find the second highest salary from emp table?
211 Answers CIS, Cognizant, Cosmosoft, DAS, EDS, GreenTech, HOV Services, IBM, Infosys, National Institute of Science and Technology, Patni, Persistent, Polaris, TCS, Wipro, Yardi, Zensar,
Which software is used for pl sql programming?
What are crud methods?
How many types of index are there?
Which sql statement is used to return only different values?
How can you fetch common records from two tables?
Write a sql select query that only returns each name only once from a table?
What is a primary key, and how is it different from a unique key?
What is a trigger in sql?
What does plvtab enables you to do when you showthe contents of pl/sql tables?
Write the alter statement to enable all the triggers on the t.students table.
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)