1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| SELECT x.player_id AS ident, x.player_nick AS nick, x.event, y.tpoints, x.points
FROM
(SELECT po.id_player AS player_id, pl.nickname AS player_nick, po.id_event AS event, po.rank AS player_rank, po.tournamentpts AS points
FROM jos_pokerpoints AS po
JOIN jos_pokerplayers AS pl ON po.id_player = pl.id
JOIN jos_pokerevents AS ev ON po.id_event = ev.id
GROUP BY po.id_player, event
ORDER BY player_id ASC , points DESC) AS x
LEFT JOIN (
SELECT t.player_id AS id, t.player_nick AS name, t.event AS tevent, t.player_rank AS trank, t.points AS tpoints
FROM (
SELECT po1.id_player AS player_id, pl.nickname AS player_nick, po1.id_event AS event, po1.rank AS player_rank, po1.tournamentpts AS points, COUNT(*) AS ordre
FROM jos_pokerpoints AS po1
JOIN jos_pokerplayers AS pl ON po1.id_player = pl.id
JOIN jos_pokerevents AS ev ON po1.id_event = ev.id
JOIN jos_pokerpoints AS po2 ON po1.id_player = po2.id_player AND po1.tournamentpts <= po2.tournamentpts
GROUP BY po1.id_player, event
ORDER BY player_id ASC , points DESC) AS t
WHERE t.ordre <=5
GROUP BY id, tevent
ORDER BY id ASC) AS y
ON x.player_id = y.id
GROUP BY ident, nick, x.event
ORDER BY ident ASC, x.points DESC |
Partager