Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Calculate Running Totals | Time-Series Aggregation
SQL for Finance and Accounting

bookChallenge: Calculate Running Totals

Task

Swipe to start coding

Write a SQL query to calculate the running total of expenses over time, using the transactions table. Only include rows where the category is 'Expense'. The results must be ordered by transaction_date. For each row, return the transaction_date, amount, description, and a column named running_total that is the sum of all amount values for expenses from the earliest to the current row (inclusive), ordered by date.

  • Filter the transactions table to include only rows where category is 'Expense'.
  • Select the transaction_date, amount, and description columns.
  • Calculate a running total of amount for each row, ordered by transaction_date, and include it as running_total.
  • Order the results by transaction_date.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 4
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookChallenge: Calculate Running Totals

Swipe to show menu

Task

Swipe to start coding

Write a SQL query to calculate the running total of expenses over time, using the transactions table. Only include rows where the category is 'Expense'. The results must be ordered by transaction_date. For each row, return the transaction_date, amount, description, and a column named running_total that is the sum of all amount values for expenses from the earliest to the current row (inclusive), ordered by date.

  • Filter the transactions table to include only rows where category is 'Expense'.
  • Select the transaction_date, amount, and description columns.
  • Calculate a running total of amount for each row, ordered by transaction_date, and include it as running_total.
  • Order the results by transaction_date.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 4
single

single

some-alt