これは私を夢中にさせています!MySQL DBMSをミューズします(それを指定して申し訳ありません)...
私は次の表を持っています:
"id", "pingdate", "players"
"3","2012-05-24 11:45:04","63"
"1","2012-05-24 12:15:03","14"
"2","2012-05-24 12:15:03","38"
"3","2012-05-24 12:15:03","24"
"1","2012-05-24 12:45:04","22"
"2","2012-05-24 12:45:04","40"
"3","2012-05-24 12:45:04","66"
"1","2012-05-24 13:15:03","14"
"5","2012-05-24 13:15:03","99"
"3","2012-05-24 13:15:03","63"
"3","2012-05-24 13:15:03","38"
"4","2012-05-24 13:15:03","63"
次の結果が欲しい:
"5","2012-05-24 13:15:03","99"
"3","2012-05-24 12:45:04","66"
"4","2012-05-24 13:15:03","63"
テキストでは、最高のプレーヤーと正しいpingdateを持つ3つの異なるIDが必要です。
これを試しましたが、間違ったpingdateが返されます。
SELECT id,
pingdate,
max(players) AS players
FROM pings
GROUP BY id
ORDER BY players DESC
LIMIT 3