how to find the second highest salary from emp table?
Answer Posted / dsr
query:
======
select e.name,e.salary from emp e where &n =(select
count(distinct ee.salary) from emp ee where e.salary<=e.salary)
after run enter n value:
if 2 enter second max salary will come
if 3 enter third max salary will come.
otherwise, we can write below
select e.name,e.salary from emp e where 2 =(select
count(distinct ee.salary) from emp ee where e.salary<=e.salary)
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How many commands are in sql?
What is percent sign in sql?
Can a trigger call a stored procedure?
What are primary key and foreign key and how they work?
What is an example of translating a date into julian format?
What is on delete restrict?
What is a sql*loader control file?
Is keyword pl sql?
how do you login to mysql using unix shell? : Sql dba
What is the file extension for sql database?
Mention what does plvtab enables you to do when you showthe contents of pl/sql tables?
Do stored procedures prevent sql injection?
How does index help in query performance?
what are the difference between clustered and a non-clustered index? : Sql dba
how to delete duplicate rows from a join tables(I have three tables on that join) how do you know which join is need to be used? The select statement I have is: SELECT gc_skill_type.skill_type, gc_area_tec.area, gc_technology.technology, gc_technology.id_technology, gc_area_tec.id_area_tec FROM gc_skill_type, gc_area_tec, gc_technology WHERE gc_area_tec.id_skill_type (+) = gc_skill_type.id_skill_type AND gc_technology.id_area_tec (+) = gc_area_tec.id_area_tec order by gc_skill_type.skill_type asc, gc_area_tec.area asc, gc_technology.technology asc