Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Posts
    6

    Unanswered: Getting an especific row

    Hi,

    I need your help .. the problem is as follows:

    I have a simple select sentence, like this:

    SELECT partnum, provider FROM parts;

    Which returns a set of records ... In my application, I need to obtain only the row number N from the resultset .. I,m trying with the ROWNUM sentence, but this doesn't work on an especific row ... like this:

    SELECT partnum, provider FROM parts WHERE ROWNUM=200;

    No rows selected.

    It's posible do it? How can I do it?? ..

    Best regards!

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >It's posible do it?
    NO!
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Apr 2003
    Location
    NY
    Posts
    208
    You can use an in-line view, but it is not recommended on large tables.

    Also, oracle doesn't track the "order" of things, so if you want to apply an order, you will have to define it.

    So define what the 200th element would be.

    In the example below, I used Date_Added as an example of how to apply ordering.

    Code:
    SELECT a.partnum, a.provider
    FROM (SELECT rownum nm, partnum, provider, date_added 
              FROM parts
              ORDER BY date_added)
    WHERE a.nm = 200
    HIH

  4. #4
    Join Date
    Jan 2003
    Location
    China
    Posts
    38
    SELECT A.partnum, A.provider FROM(SELECT partnum, provider,rownum RN FROM parts) A WHERE A.RN = X
    X is the number of the row which you want to get.
    By the way,ROWNUM is the row's number(i.e. order) in the records returned by the query.So,if you use 'WHERE RUMNUM = 100',you will get nothing.
    Fan Yi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •