how to find nth lowest salary

Answers were Sorted based on User's Feedback



how to find nth lowest salary..

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

how to find nth lowest salary..

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

how to find nth lowest salary..

Answer / mohd javed

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

how to find nth lowest salary..

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

Post New Answer

More Postgre Interview Questions

How do I set up postgresql?

0 Answers  


What is use of postgresql?

0 Answers  


Do foreign keys speed up queries?

0 Answers  


How do you check data on pgadmin 4?

0 Answers  


How many rows can postgresql handle?

0 Answers  






How to start database server in postgresql?

0 Answers  


Does PostgrSQL support Column constraints? If so how is it done?

0 Answers  


How is postgresql different from oracle?

0 Answers  


How to change postgresql root user password?

0 Answers  


Is postgres distributed?

0 Answers  


How do I enable remote access to postgresql database?

0 Answers  


What is the driver name for postgresql?

0 Answers  


Categories