OK, let's first format the SQL so we can read it (
http://www.sqlinform.com/)
SELECT
f.currency,
sum(cast(f.balance AS bigint)) AS amount,
f.id
FROM Finance AS f
WHERE f.currency in ('CAD','USD')
GROUP BY f.currency,
rollup(f.user_id)
ORDER BY f.currency ASC.
The ORDER BY is probably not necessary since it is the first column in the GROUP BY. DB2 sorts the rows in order of the GROUP BY.
I am not an expert on ROLLUP, but did you try this:
SELECT
f.currency,
sum(cast(f.balance AS bigint)) AS amount,
f.id,
n.name
FROM Finance AS f,
Names AS n
WHERE f.currency in ('CAD','USD')
AND f.id = n.id
GROUP BY f.currency,
rollup(f.user_id, n.name)