Home » SQL & PL/SQL » SQL & PL/SQL » Selecting a specific row number
Selecting a specific row number [message #36373] Thu, 22 November 2001 02:57 Go to next message
Antonis
Messages: 1
Registered: November 2001
Junior Member
Hi to all,

I just want to select a specific row number from a table.
I have actually tried :
select * from [[table]] where rownum = 1
and it works but only for the first row ...
if you put 2 3 4 ... it's not working

Also rowid is returning nothing ....

If there is a simple way to do this please ...

Thank you

----------------------------------------------------------------------
Re: Selecting a specific row number [message #36376 is a reply to message #36373] Thu, 22 November 2001 04:05 Go to previous messageGo to next message
Rob Baillie
Messages: 33
Registered: November 2001
Member
Your method fails since the rownum is the number of the record returned by the where clause and the first record to succeed is always 1. Thus '=1' succeeds (the first row), but '=2' does not (the first record back is rownum = 1, and is thrown out, the second record is then still rownum = 1, and is thrown out, etc, etc)

So, =1 (or < n) will always succeed for a number of rows, != 1 (or any other that excludes 1) will not.

Instead, try

Select *
From ( Select /field_list/
, rownum row_number
From /table/ )
Where row_number = 2

----------------------------------------------------------------------
Re: Selecting a specific row number [message #36422 is a reply to message #36373] Tue, 27 November 2001 01:18 Go to previous message
abaid
Messages: 1
Registered: November 2001
Junior Member
hi
i wana sql and pl/sql oracle8i ceritification paper i want to prepare pracle8i ceritification
test.
plz send me very soon
good blees u

----------------------------------------------------------------------
Previous Topic: Re: pl/sql send email with attachment
Next Topic: Re: Arrays of Records ?
Goto Forum:
  


Current Time: Sat Apr 20 10:46:53 CDT 2024