ROLLUP generates subtotals and a grand total.
Example:
SELECT department, team, SUM(salary) FROM employees GROUP BY ROLLUP(department, team);
It can produce:
IT Backend 100000 IT Frontend 80000 IT NULL 180000 ← IT subtotal HR Recruitment 50000 HR NULL 50000 ← HR subtotal NULL NULL 230000 ← Grand total
Useful for reports.