I ran in to this problem on a CS question site, and I can't figure out how to do this.
My first solution ran in to a dead end with this code
SELECT
recipient
FROM
transfers
GROUP BY
recipient
HAVING
sum(amount) >= 1024
ORDER BY
recipient ASC;
But there is no way to put a limit on the sum to sum the largest 3 values.
Another idea was to create a subquery and join the two tables.
like so
SELECT
recipient,
( SELECT SUM(amount)
FROM transfer t1
WHERE t1.recipient = t.recipient ORDER BY amount DESC LIMIT 3) as summedValue
FROM
transfer t
However, that summed all the values and not just the top three also.