I have this query that echoes all rows prior a particular date.
SELECT MAX(h.date), h.url
FROM HISTORY h
WHERE h.uid = '19'
AND h.date < (SELECT MAX(t.date)
FROM History t
WHERE t.url = 'canabalt.com'
AND t.uid = '19')
GROUP BY h.url
ORDER BY MAX(h.date) DESC
My problem is that I must only select rows that have max(Date).
But the where clause eliminates a number of rows that may have the max(Date) row and then looks for max(Date) in the remaining fields.
How can I first SELECT max(Date) and only afterwards run the WHERE clauses.
Try placing your criteria in the Having clause which is processed after the Group By clause.