MySQL Forums
Forum List  »  Newbie

MySQL 4. Problem with min() and GROUP BY
Posted by: Ole Hansen
Date: June 04, 2005 07:52AM

Hi,

I wish to select the value of IDrecord with the oldest date from the table contenttracking. However when using min() and GROUP BY it seems to be mixing different entries in the table.

Table:

Contenttracking
=======================================
ID IDcontent IDrecord time
---------------------------------------
1 329 17 2005-05-29 13:46:49
2 329 24 2005-05-29 20:33:57
=======================================


Query:

SELECT IDcontent, IDrecord, min( time ) AS time
FROM contenttracking
GROUP BY IDcontent


Result host (MySQL 4.?.?):

=======================================
IDcontent IDrecord time
---------------------------------------
329 24 2005-05-29 13:46:49
=======================================

Result on my own testserver (MySQL 4.0.23):

=======================================
IDcontent IDrecord time
---------------------------------------
329 17 2005-05-29 13:46:49
=======================================

In the result on my web host the correct date is selected however the result is merged with a different entry of IDrecord. How do I make sure it returns the value of IDrecord related to the correct time?

Regards,

J.R.

Options: ReplyQuote


Subject
Written By
Posted
MySQL 4. Problem with min() and GROUP BY
June 04, 2005 07:52AM


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.