How do you calculate a running total or percentage of total?
Model answer
Running total with a window function: SUM(amount) OVER (ORDER BY date). Percentage of total: amount * 100.0 / SUM(amount) OVER (). Window functions keep every row, unlike GROUP BY.
Learn this topic
GROUP BY and HAVING: Summaries for Each Group in the course SQL for Beginners: Learn Databases Step by Step.
Sign in to add your own answer.