Welcome to the OzoneAsylum FaqWiki |
How do I find the maximum value of a grouped field? |
---|
Say you have league table recording the positions of the rankings of each player over time but you want to find the most recent rank for each player. It can get quite complex and messy as you need to use GROUP BY and some work arounds for this require temporary tables and truly scarey lookin SQL. The trick (takn from Csaba Gabor's comments in the MySQL manual) involves joinging the table to itself and then going through it (with the < ) until there are no more date values (i.e. you have found the highest date). It would work something like this: code: SELECT *
|