RienSQL
TASK #172 · Medium · N26

Spending by Merchant Category

Your brief
In the transactions table consider only the rows with transaction_type = 'card_purchase' (they have a non-NULL merchant_category).

Write a query that for every category returns merchant_category, total_spent (sum of amounts, rounded to two decimals) and num_purchases — the number of transactions in that category. Sort by total_spent descending.
Expected columnsmerchant_category total_spent num_purchasesN26
SQL editor
SQLite
Ctrl / ⌘ + ↵
Result

Write a query and run it to see the results.

Schema
customerscustomer_id, name, country, signup_date
transactionstransaction_id, customer_id, transaction_type, amount, merchant_category, transaction_at