Women in Technology

Hear us Roar



Article:
  SQL Data Types
Subject:   how do we find nth highest in SQL
Date:   2005-01-28 13:02:12
From:   parangogoi
Response to: how do we find nth highest in SQL

Please help me with the above query
Full Threads Oldest First

Showing messages 1 through 4 of 4.

  • how do we find nth highest in SQL
    2005-10-17 23:29:32  Apurva_Sharma [View]

    Hi,
    Solution to your query.Plz follow steps.

    Steps
    SQL> SET Verify OFF;

    SQL> SELECT min(sal)
    FROM (SELECT sal
    FROM emp
    order by sal desc)
    WHERE rownum<(&nth_heighest+1);
    • how do we find nth highest in SQL
      2005-10-30 09:21:35  bhaskarreddy [View]

      select * from emp e where 1=(select count(distinct sal) from emp where e.sal<=sal)
      if u want to print the second highest sal. replace 1 with 2.
      • how do we find nth highest in SQL
        2006-10-17 02:09:39  Asha_S [View]

        very useful query for interviews... thanks
        • how do we find nth highest in SQL
          2010-05-11 00:05:08  vish44 [View]

          This query only work till 3rd highest, after that it gives 4th highest when we set n=7