how to find nth lowest salary
Answers were Sorted based on User's Feedback
Answer / liju
nth lowest
nth lowest
*******************************************************
SELECT DISTINCT (A.sal) FROM EMP A WHERE (N-1) =
(SELECT COUNT (DISTINCT (b.sal)) FROM EMP B
WHERE b.sal<a.sal);
nth highest
*******************************************************
SELECT DISTINCT (A.sal) FROM EMP A WHERE (N-1) =
(SELECT COUNT (DISTINCT (b.sal)) FROM EMP B
WHERE b.sal>a.sal);
| Is This Answer Correct ? | 14 Yes | 3 No |
Answer / hari.sidd
SELECT DISTINCT (A.sal) FROM EMP A WHERE &N =
(SELECT COUNT (DISTINCT (b.sal)) FROM EMP B
WHERE a.sal>=b.sal);
| Is This Answer Correct ? | 7 Yes | 0 No |
For All SQL , Tested in PostgresSQL : Javedcc@gmail.com
SELECT * FROM <Table_Name> A
WHERE N = (SELECT COUNT(DISTINCT B.Column_Name ) FROM
<Table_Name> B WHERE A.Column_Name >= B.Column_Name)
| Is This Answer Correct ? | 8 Yes | 6 No |
Answer / ezhumalai
with cte
as
(
select Salary,row_number() over ( order by Salary asc)rnt from EMP
)select * from cte where rnt=2
| Is This Answer Correct ? | 2 Yes | 0 No |
Where is pgadmin installed?
Who created postgresql?
How do I change the order of columns in postgresql?
What is the powerful database utility that can be used for building, executing and processing queries upon PostgreSQL databases?
What does mvcc mean?
How to access postgresql database from another machine?
How do I stop a postgresql console?
How do I change the default port for postgresql?
Who maintains postgresql?
What is logical replication in postgresql?
Is postgresql case sensitive?
How do I delete a query?
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)