I am unsure on how to google this, so let me just try to explain. Train numbers are a slot in a timetable, and hence repeat everyday. For each train, there are a set of events from start to finish, and those events include a value for the current weight. What I would like to find out is the peak per train. If I just wanted the peak, it would just be a select *, max(weight)..., but I want it done by train number so that I can get the date/time and station name. I want something along the lines of:
SELECT train, weight, date, station FROM event_table WHERE date >= '2010/10/03'
AND date <= '2010/11/03' ORDER BY weight DESC LIMIT 1 GROUP BY train
But obviously the GROUP BY can't be after the limit. My option is ignoring the limit and filtering it out in PHP, but it's wasted cycles and bandwidth, which might be a problem in the future.
Thanks