SELECT cardId, pageId, transactionId
FROM (
    SELECT cardId, pageId, transactionId, ROW_NUMBER() OVER (
        PARTITION BY cardId ORDER BY timestamp DESC
        ) AS rowNumber
    FROM transactions
    JOIN cards
    WHERE receiver == {userId}
) AS subquery
WHERE rowNumber == 0;
