i have a dummy question
table game_log
| id | game_id | score| user_id | created_at
|1 | 1 | 100 | 1 | 2015-01-01 00:00:00|
|2 | 1 | 200 | 2 | 2015-01-01 10:00:00|
|3 | 2 | 100 | 2 | 2015-01-01 00:00:00|
|4 | 2 | 500 | 1 | 2015-01-01 01:00:00|
|5 | 2 | 900 | 4 | 2015-01-01 03:00:00|
|X | 2 | 500 | 1 | 2015-01-02 02:00:00|
|Y | 3 | 600 | 1 | 2015-01-02 01:00:00|
i need to create a game rating with user ids by date 2015-01-01 result will looks like
| id | game_id | score| user_id | created_at
|2 | 1 | 200 | 2 | 2015-01-01 10:00:00|
|5 | 2 | 900 | 4 | 2015-01-01 03:00:00|
i tried something like
SELECT p.id, p.score, p.game_id, p.user_id
FROM (
SELECT *
FROM game_log
WHERE game_log.score>0
AND game_log.created_at >="2015-01-01 00:00:00"
AND game_log.created_at <"2015-01-02 00:00:00"
ORDER BY score DESC ) AS p
GROUP BY p.game_id
ORDER BY score DESC ;
but get results without order
thank you!
ORDER BY
withoutLIMIT
in subqueries. Why is ORDER BY in a FROM Subquery Ignored?