ГС
Size: a a a
ГС
DE
DE
ГС
DE
DE
ГС
DE
DE
sql
SELECT `L`.`first` AS `first`,
`L`.`second` AS `second`,
count(`L`.`game`) AS `games`,
sum(`L`.`moves`) AS `moves`
FROM
( SELECT count(`M`.`id`) AS `moves`,
`G`.`id` AS `game`,
`format_user_name`( greatest( `W`.`id`, `B`.`id` ) ) AS `first`,
`format_user_name`( least(`W`.`id`, `B`.`id`) ) AS `second`
FROM ( ( ( `chess`.`games` `G`
JOIN `chess`.`moves` `M` ON ( ( `M`.`game_id` = `G`.`id` ) ) )
JOIN `chess`.`users` `W` ON ( ( `G`.`whites_id` = `W`.`id` ) ) )
JOIN `chess`.`users` `B` ON ( ( `G`.`blacks_id` = `B`.`id` ) ) )
GROUP BY `M`.`game_id` ) `L`
GROUP BY `L`.`first`,
`L`.`second`
ORDER BY `games` DESC,
`moves` DESC
DE
ГС
DE
DE
DE
DE
DE
DE
ГС
ГС