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

bookChallenge: Quarterly Expense Report

Task

Swipe to start coding

Write a SQL query to calculate the total expenses for each quarter using the transactions table. Only include rows where the category is 'Expense'. Aggregate the amount by quarter, grouping the results by quarter.

  • Filter the rows in the transactions table to include only those where category is 'Expense'.
  • Group the filtered rows by quarter, using the transaction_date to determine the quarter and year.
  • Calculate the sum of the amount for each quarter.
  • Return the quarter (in the format YYYY-Qn) and the total expenses for that quarter.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 6
single

single

Ask AI

expand

Ask AI

ChatGPT

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

Suggested prompts:

Can you explain this in simpler terms?

What are the main benefits or drawbacks?

Can you give me a real-world example?

close

bookChallenge: Quarterly Expense Report

Swipe to show menu

Task

Swipe to start coding

Write a SQL query to calculate the total expenses for each quarter using the transactions table. Only include rows where the category is 'Expense'. Aggregate the amount by quarter, grouping the results by quarter.

  • Filter the rows in the transactions table to include only those where category is 'Expense'.
  • Group the filtered rows by quarter, using the transaction_date to determine the quarter and year.
  • Calculate the sum of the amount for each quarter.
  • Return the quarter (in the format YYYY-Qn) and the total expenses for that quarter.

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Β 6
single

single

some-alt