Women in Technology

Hear us Roar



Subject:   how do we find nth highest in SQL
Date:   2004-12-11 08:16:41
From:   RuchirAwadhawal
Response to: how do we find nth highest in SQL

Query for Nth Max (Highest)
select sal from emp t
where &n = (select count(sal)
from (select distinct sal from emp)
where t.sal<=sal);


<b>Query for Nth Min (Lowest)
select sal from emp t
where &n = (select count(sal)
from (select distinct sal from emp)
where t.sal>=sal);

Main Topics Newest First

Showing messages 1 through 1 of 1.

  • query for nth max
    2007-08-25 02:05:46  kashif094 [View]

    select * from emp e where 1=(select count(distinct sal) from emp where e.sal<=sal)



    hi i am kashif can anyone tell me what is the concept of 1 in this query?