MySQL Forums
Forum List  »  Newbie

Re: Getting to row number
Posted by: Roland Bouman
Date: July 28, 2005 02:26PM

Hi!

you could do this if you cannot use a subquery:

select t1.id, count(t2.id) as rownum
from t as t1
inner join t as t2
on t1.id <= t2.id
group by t1.id


and if you need to scoop out a particular row, just add:

having count(t2.id) = <preferred rownum>

it's bound to be more expensive than Russels' solution (Good one! thanks!)

Options: ReplyQuote


Subject
Written By
Posted
July 27, 2005 11:27PM
July 28, 2005 01:29AM
November 25, 2008 05:54AM
Re: Getting to row number
July 28, 2005 02:26PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.