MySQL Forums
Forum List  »  Newbie

two conditions in having
Posted by: kernel kernel
Date: September 01, 2007 06:41AM

hi ,
i want to pull out in one DB transaction two rows per paperName (group by) which are the min and the max of date field , i need the entire rows not the fields
SELECT * FROM simplepapereod
GROUP BY PAPERNAME
HAVING DATE = MIN(DATE) or DATE=MAX(DATE)
obviously doesn't work but i haven't been able to find out how to pull two rows per distinct papername in one query ... any ideas ?
thanks in advance .
select * from simplepapereod group by papername having date = min(date)
this is getting me the right data when i change the min to max it retrieves empty result ???



Edited 1 time(s). Last edit at 09/01/2007 07:22AM by kernel kernel.

Options: ReplyQuote


Subject
Written By
Posted
two conditions in having
September 01, 2007 06:41AM
September 01, 2007 09:51AM
September 01, 2007 03:35PM


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.