I have a table where I record multiple scores from users daily. I'm trying to create a query where I get the distinct top 5 weekly winners for each week that passes...
Is it that I need to do a sub query grouping results in both max score and date week? or do I need to do 2 sub queries one for the date another for max score then use the outer query to group?
Well the table structure would be:
NAME,
SCORE,
DATE
I came up with this
SELECT *
FROM `highscores`
WHERE id IN ((SELECT id
FROM highscores
WHERE WEEK(date) IN (SELECT DISTINCT WEEK(date)
FROM highscores)
ORDER BY score DESC))
GROUP BY email
ORDER BY date, score DESC
But apparently I can't use LIMIT in sub-queries