Hello, I have this table: id created_at title views ---|-------------------|--------|--------- 1 | 2012-12-25 | john | 399 2 | 2012-11-23 | juliet | 244 5 | 2012-11-12 | borat | 555 7 | 2012-07-05 | osama | 600 8 | 2012-06-25 | borat | 345 9 | 2012-04-25 | borat | 403 10 | 2012-02-25 | gorat | 123 11 | 2012-03-22 | obama | 675 How do I select so as to get the first 5 highest titles ordered by the most recent date? I use this query, but not work... SELECT id, title, created_at, MAX( views ) FROM article GROUP BY created_at LIMIT 5 PHP:
Try this SELECT id, title, created_at, MAX( views ) FROM article GROUP BY id, title, created_at LIMIT 5 Code (markup):
In T-SQL SELECT TOP 5 id, title, created_at, MAX( views ) FROM article GROUP BY id, title, created_at ORDER BY Max( views) desc, created_at Code (markup):