Home » RDBMS Server » Server Administration » selecting the nth record
selecting the nth record [message #371761] Sun, 03 December 2000 15:38 Go to next message
Gus
Messages: 18
Registered: December 2000
Junior Member
Hi,

does anyone know how I can select the nth row of a table? I'm using ASP to query an Access db and I need something like:

SELECT * FROM myTable WHERE --rowNumber-- = n

but where rowNumber is not a field in my table but some sort of independant system thing, does that make sense?

Any help much appretiated,

Gus
Re: selecting the nth record [message #371784 is a reply to message #371761] Tue, 05 December 2000 06:57 Go to previous messageGo to next message
Tittom
Messages: 15
Registered: November 2000
Junior Member
You can use rownum, but not in this way. Rownum can be use onely with the "<" and "<=" operators (otherwise you will get an empty result with no error message).
In order to get the fifth row (for instance), the idea would be to do somethnig like this :

select * from (select table.*, rownum as numb from table where rownum <=5) where numb=5

I hope this helps
Tittom.
Re: selecting the nth record [message #372103 is a reply to message #371761] Wed, 10 January 2001 06:29 Go to previous message
Sandeep Udupa
Messages: 9
Registered: January 2001
Junior Member
If you want to reterive the Nth row then your query should look like this.

SELECT * FROM

WHERE rownum <= n
MINUS
SELECT * FROM

WHERE rownum <= n-1;
where n being the row you are trying to reterive
Previous Topic: Business Days
Next Topic: display "NULL" for null value ?
Goto Forum:
  


Current Time: Sat May 18 01:40:21 CDT 2024