how to find the second highest salary from emp table?
Answers were Sorted based on User's Feedback
Answer / vinod
SELECT MAX(SAL) FROM TEST_123 WHERE SAL NOT IN (SELECT
MAX(SAL) FROM TEST_123)
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / udayalakshmij
select emp_name,max(salary) from emp except(select max(salary) from emp);
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / amarendra swain
select max(sal) from employee
where sal not in (select max(sal) from employee )
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / shankar panda
SELECT DISTINCT(E.SALARY) FROM EMPLOYEES E WHERE 2=(SELECT COUNT(DISTINCT D.SALARY) FROM EMPLOYEE D WHERE D.SALARY >= E.SALARY)
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / sreenadh reddy
select max(sal) from emp where sal <(select max(sal) from
emp)
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / bharath konegadde
Select Emp_Name from emp_table where Id=(Select Emp_Id from Salary Order By salary Desc limit 0,1)
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / chiguru&
SELECT MAX(SALARY) FROM EMPLOYEE WHERE SALARY NOT IN
(SELECT MAX(SALARY) FROM EMPLOYEE)
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / mohan rathour
select max(e1.salary) from Emp_table e1 where e1.salary not
in (select max(e2.salary) from Emp_table e2 )
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / harish
select * from emp where 2=(select count(distinct sal) from emp s where s.sal>e.sal
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / manikishore
select * from emp e where
2 =(select count(distinct sal) from emp where e.sal<=sal);
//if you want to retrieve 3rd max(sal) then you can use 3 in place of 2,,,like that for so on..
Is This Answer Correct ? | 1 Yes | 1 No |
What are the different ddl commands in sql?
What is equi join in sql?
How to trace the errors in pl/sql block code?
How many types of database triggers can be specified on a table ? What are they ?
What is partition in sql query?
What is crud sql?
While inserting 10 rows using procedure, if 3rd entry is having some error, what will be the output? How u will handle that error?
in table there r so many rows write a query which two rows r updated last two day befor?
What are the main features of cursor?
What are database links used for?
How do I tune a sql query?
is it mandatory to select all the column in a view then what columns should be selected