MySQL Forums
Forum List  »  General

query that returns nth result
Posted by: guic horton
Date: January 28, 2005 03:56PM

I'm looking for a way to query for the nth result in a result set according to a certain field, such as a date field. For example
table1
fields:holiday(values: christmas,new years,thanksgiving), start_date(values:2005-12-25,2005-01-01,2005-11-25)

I want a way to select the second start_date.
min and max will easily return the first and last start_date:
SELECT MIN(start_date) FROM table1

but I can't find any easy way to select the nth result. The only way I've thought of involves iterating subqueries that find the minimum from a result set that must be greater than the initial minimum, but that is way too slow if you are looking for the 8th or ninth iteration.

Options: ReplyQuote


Subject
Written By
Posted
query that returns nth result
January 28, 2005 03:56PM


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.