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 |
What are the most common databases?
WHAT IS THE PURPOSE OF TESTING INTEGRITY OF THE UNIVERSE?
Is it good to store images in database?
What is a super key?
What is a Database?
hOW TO LOAD SOURCE INTO TARGET 2 TIMES?(INFORMATICA)
where can i free download sqlserver2008..i can install sqlserver2008 without visual studio 2008 and work on it
what is primary key,unique key, foreign key? can u teach me in simple language?
44 Answers Banking, CMC, CTS, HCL, Infosys, Keggfarms, SkyEss, Sunrise, TCS, Web Synergies, Wipro,
What are the three types of anomalies in database and Explain?
If we execute an query in MLOAD it's ran successfully, my questions is after successfully ran MLOAD. In error tables we can see anything there! is it possible than what are they?
How can we join three tables in SQL server 2000
What is the importance of database partitioning?
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)