Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Transaction Type Breakdown | CASE WHEN for Aggregates and Reporting
Mastering CASE WHEN in SQL
Sectionย 4. Chapterย 5
single

single

bookChallenge: Transaction Type Breakdown

Swipe to show menu

Task

Swipe to start coding

Write a query that, for each month, shows the count of transactions of type 'purchase', 'refund', and 'fee' as separate columns.

  • For each month in the transactions table, count how many transactions have transaction_type equal to 'purchase'.
  • For each month, count how many transactions have transaction_type equal to 'refund'.
  • For each month, count how many transactions have transaction_type equal to 'fee'.
  • Show the results with one row per month, and columns for the month, purchase count, refund count, and fee count.

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ย 4. Chapterย 5
single

single

Ask AI

expand

Ask AI

ChatGPT

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

some-alt