write a query for the fifth highest salary?
Answers were Sorted based on User's Feedback
Answer / venkates
select distinct(a.sal) from emp a where 5=(select
count(distinct(b.sal)) from emp b where a.sal<=b.sal)
Is This Answer Correct ? | 22 Yes | 2 No |
Answer / nitin bisht
SELECT empSalary FROM empTable e1 WHERE (5 = (SELECT
COUNT(DISTINCT (e2.empSalary))
FROM empTable e2 WHERE e2.empSalary >= e1.empSalary))
Is This Answer Correct ? | 13 Yes | 0 No |
Answer / piyush gupta
select distinct(a.sal) from emp a where 5=(select
count(distinct(b.sal)) from emp b where a.sal<=b.sal)
you can this query for nth highest salary
replace 5 with any number
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / prasanna
select max(sal) from emp where sal not in (select Top 4 sal
from emp order by sal desc)
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / shahid
select *from(select sal,rank() over(order by sal desc)as sal_rank from emp) where sal_rank=5;
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / bhramar
select top 1 Sal from(select distinct top 5 Sal from TestEmp order by Sal desc) a order by Sal
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / suparna
select salary from employee e where 4=(select count(*) from
emp f where e.sal<f.sal)
Is This Answer Correct ? | 8 Yes | 8 No |
Answer / chethan
select Salary from ( select salary from emp order by desc) as employee where rownum = 5;
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / bezalel
select salamt from
(
select rownum n,salamt from
(
select distinct salamt from emp order by salamt desc
)
)
where n=5
Is This Answer Correct ? | 0 Yes | 0 No |
Given a table Employee which has columns name and salary, write an SQL query to find the employee with the second highest salary.
Give the syntax of exception handling used in DBMS?
What are the types of indexes that are present inside a database?
What is database server and how it works?
What is the difference between oracle and MS Access?
what is data set ?
What is the purpose of firebase?
Define the following terms i. Inverted List ii. Candidate Key iii. B-Tree iv. Foreign Key
What is the function of cluster index?
Explain inner and outer joins with examples.
How do you pass parameter in stored procedure?
What is global database name?