id, того самого, максимального значения?
`SELECT
"name",
"currency",
count("id") AS "games",
sum("amount") AS "bets",
max("amount") AS "max_amount",
max("profit") AS "max_profit"
FROM
"game" AS "Game"
WHERE
"Game"."user_id" = '123'
GROUP BY
"name",
"currency";`
select * from table t join (запрос выше с группировками) g on t."name"=g."name" and t."currency"=g."currency" and t."amount"=g."max_amount" ;
Обсуждают сегодня