MySQL Forums
Forum List  »  General

Select most recent record of each category
Posted by: steve.groom
Date: February 16, 2005 02:11PM

Hello,
I've been racking my brain trying to get this query to work correctly:

SELECT MAX(gt_news_date), gtnews.gt_series,
gt_news_title, gt_news_image, gt_news_summary
FROM gtnews, gtseries
WHERE gtseries.gt_series = gtnews.gt_series
GROUP BY gt_series
ORDER BY gt_weight ASC

The gtnews table is fairly straigtforward. The gt_series column is to set a sub category the gtseries table is there to give the desired sequence.

The problem:
On the surface this works, but after looking carefully I correctly get the max(gt_news_date) but the gt_news_title for example is not the one associated with that date.

I guess that I'm not allowed to mix MAX with other values.

Any help much appreciated.

best regards
Steve Groom

Options: ReplyQuote


Subject
Written By
Posted
Select most recent record of each category
February 16, 2005 02:11PM


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.