SQL QuestSQL Interview Questions › Aggregation & Grouping

Card Spend by Category, August 2026

EasyFreeQuerying BasicsAggregation & Grouping

The warm-up on a neobank screen: what did people buy last month? The transactions table holds every event on the ledger — card payments, transfers, FX, fees — with a type, a status and an ISO timestamp in ts. Keep only completed card payments made in August 2026 (ts from 2026-08-01 up to but not including 2026-09-01).

Return merchant_category, payments (row count) and spend_gbp (SUM of amount_gbp, rounded to 2 decimals), one row per category. Order by spend_gbp descending.

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

transactions

txn_iduser_idtstypeamountcurrencyamount_gbpfee_gbpmerchant_categorymerchant_countrycounterparty_user_idstatusdecline_reason
112025-06-14 11:01:51fx_exchange32271.15JPY167.811.68NULLNULLNULLcompletedNULL
212025-06-14 11:17:45bill_payment59.53EUR50.60utilitiesIENULLcompletedNULL
372025-06-16 10:06:38card_payment122.27EUR103.930shoppingESNULLcompletedNULL

Expected output: merchant_category=travel, payments=10, spend_gbp=3437.83 ...

Hint

Filter on type, status and a half-open date range (ts >= '2026-08-01' AND ts < '2026-09-01' — string comparison works on ISO timestamps), then GROUP BY merchant_category.

Concepts

SELECT WHERE GROUP BY SUM COUNT GROUP BY + Filtering

Practise the topic: SQL practice questions · GROUP BY exercises

In these company practice sets

Revolut

A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.

Related questions

Counting RowsEasy · FreeSUM, AVG, MIN, MAXEasy · FreeGROUP BY BasicsEasy · FreeMonthly Order CountEasy · FreeHow Many Genres Do We Cover? (DISTINCT)Easy · FreeFemale Survivor CountEasy · Free

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test