how to find the second highest salary from emp table?
Answers were Sorted based on User's Feedback
Answer / gaurav singh 'viccky'
select salary from user=(select max(salary)from user where
salary < (select max(salary)from user))
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / arjunraj
aa means table-alias name
bb means table-alisa name
select * from emp aa where 2=(select count(distinct empsalary) from emp bb where aa.empsalary<=bb.empsalary)
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / dakshin
select * from (select a.*,dense_rank() over (order by sal) rnk from emp a order by sal) where rnk =2
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / kishor dange
select max(sal) from table_name where sal<(select max(sal)
from table_name)
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vikas
select top 1 salary from emp
where salary in (select top 2 salary from emp order by salary desc)order by salary
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ashwini
select max(salary) from employee where salary < (select max(salary) from employee)
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / manjusha
select * from emp e1
where 2=(select count(distinct salary) from emp e2
where e1.sal<e2.sal);
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / hari thorat
select max(salary) from employee where salary <(select max(salary) from employee);
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / gunjal ghagre
Select sal from table_name order by sal desc limit 1,1;
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / debasish
select ename,sal from (select ename,sal,row_number()
over(order by sal desc)rn from emp)
where rn=1;
Is This Answer Correct ? | 0 Yes | 0 No |
What is java sql driver?
What is rownum in sql?
What is sql table?
What are expressions?
Which operator is used in query for pattern matching?
what is user defined functions? : Sql dba
What is a table?
what is data control language? : Sql dba
a. Can you delete data from a View. b. If Yes, can you delete it if there are multiple tables c. If No, can you delete if there is single source table which is joining.
What is string join?
What is sql profiling in oracle?
What is sql resultset?