By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
with CTE AS (SELECT 1 as amt, 'a' team from dual UNION ALL
SELECT 1 as amt, 'a' team from dual UNION ALL
SELECT 1 as amt, 'a' team from dual UNION ALL
SELECT 2 as amt, 'b' team from dual UNION ALL
SELECT 3 as amt, 'c' team from dual)
SELECT sum(Amt), coalesce(team,'TOTAL')
FROM CTE
GROUP BY rollup (team)
SUM(AMT) | COALESCE(TEAM,'TOTAL') |
---|---|
3 | a |
2 | b |
3 | c |
8 | TOTAL |