Challenge: 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
transactionstable to include only those wherecategoryis'Expense'. - Group the filtered rows by quarter, using the
transaction_dateto determine the quarter and year. - Calculate the sum of the
amountfor each quarter. - Return the quarter (in the format
YYYY-Qn) and the total expenses for that quarter.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 1. ChapterΒ 6
single
Ask AI
Ask AI
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?
Awesome!
Completion rate improved to 4.55
Challenge: 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
transactionstable to include only those wherecategoryis'Expense'. - Group the filtered rows by quarter, using the
transaction_dateto determine the quarter and year. - Calculate the sum of the
amountfor each quarter. - Return the quarter (in the format
YYYY-Qn) and the total expenses for that quarter.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 1. ChapterΒ 6
single