Women in Technology

Hear us Roar



Article:
  SQL Data Types
Subject:   Why doesn't the following query return me the nth highest value?
Date:   2005-07-28 07:34:41
From:   Suneel_Gundlapalli
select rownum,sal from (select distinct sal from emp order by sal desc) where rownum=&n;


the above query is not working. When I issue the following query, i get salaries ranked properly.


select rownum,sal from (select distinct sal from emp order by sal desc);


Its only working for the rownum=1.
Pls respond.

Main Topics Newest First

Showing messages 1 through 1 of 1.

  • Why doesn't the following query return me the nth highest value?
    2006-03-27 12:25:24  jaipalreddy [View]

    hi sunil,

    just replace = with < . u will definetly get the solution.actually rownum is assigned after retrieving the row.there lies the problem.

    anyway u try this. u will get it