Digital bank
Customers, their accounts and every transaction, January to June 2025.
customers
One row per customer. Key: customer_id. 70 rows in the larger version, 30 in the smaller.
| customer_id | int | Unique id. |
| full_name | text | Name. |
| joined_on | date | Day they became a customer. |
| segment | text | retail, premium or business. |
accounts
One row per account. A customer can have several. Key: account_id. 126 rows in the larger version, 56 in the smaller.
| account_id | int | Unique id. |
| customer_id | int | Owner. |
| account_type | text | checking, savings or credit. |
| opened_on | date | Opening day. |
| closed_on | date, nullable | Closing day. NULL while open. |
transactions
One row per posted transaction. Positive amounts are money in, negative are money out. Key: txn_id. 9,906 rows in the larger version, 4,235 in the smaller.
| txn_id | bigint | Unique id. |
| account_id | int | The account. |
| posted_at | timestamp | When it posted (UTC). |
| amount | numeric(12,2) | Signed amount, USD. |
| category | text | salary, rent, groceries, dining, travel, transfer, fees or refund. |
| merchant | text, nullable | Merchant name. NULL for salary, transfers and fees. |
Questions on this database
- Monthly money in, money out and net flowFinance wants a monthly cash-flow table for the whole bank, using every row in transactions.
- Busy accounts in May and the fees they paidThe pricing team is reviewing fees on very active accounts. Look at transactions with posted_at on or after 2025-05-01 00:00:00 and before 2025-06-01 00:00:00.
- Customers whose every account is closedThe retention team wants a list of customers who have left the bank entirely.
- Spend mix by customer segmentThe product team wants to see how each customer segment splits its everyday spending.
- Premium customers, accounts and money inRelationship managers review every customer in the 'premium' segment. A customer can have several accounts, and each account has many transactions.
- Spending by merchant partner group, NULL merchants includedPartnerships keeps a small lookup of merchants and the group each belongs to.
- Open accounts at each month end, by account typeFinance reports the number of open accounts on the last day of every month, split by account type.
- Each customer's largest single expense, with tie-breakersThe fraud team wants to see each customer's biggest purchase. An expense is a transaction with a negative amount whose category is dining, groceries or travel.
- Months each merchant ranked in the top three for spendThe cards team tracks which merchants dominate everyday spending. A transaction counts as everyday spending when its category is dining, groceries or travel.
- Favourite spending category per customer, counted by segmentThe marketing team wants to know which spending habit dominates each customer segment.
- Running balance for one bank accountA customer disputes their January statement for account 20. Rebuild it with a running balance. List every transaction on account 20 posted before 2025-02-01.
- Dining spend that restarts each monthA budgeting feature shows how much a customer has spent on dining so far this month, and the figure starts again at the beginning of each month.
- Average transactions per open accountThe product team wants to know how busy each kind of account is. Look only at open accounts (closed_on is NULL).
- Spending share by category within each segmentThe bank wants to see how each customer segment spends its money.
- Money in and money out per savings accountRisk wants a February 2025 cash-flow summary for every savings account. In transactions, a positive amount is money in and a negative amount is money out.
- Month-end balance by account typeFinance reports the combined balance of each account type at the end of every month, from January to June 2025.
- Biggest month-over-month spending drop per categoryThe cards team wants to know in which month customers cut back the most in each everyday spending category.
- Customers with savings but no open checking accountThe bank wants to offer a checking account to customers who save with them but do not have one to spend from. An account is open when closed_on is NULL.
- Customer activation funnel by segmentThe bank tracks how many new customers become active.
- Median dining spend by month, without percentile functionsA reporting tool in your company only supports plain SQL: no percentile_cont, no percentile_disc.
- One row per savings account per month, with zero fillBuild a monthly fact table for savings accounts at the grain one row per account per calendar month, for January to June 2025.
- Daily end-of-day balance from transactions with a date spineThe bank wants a daily balance table for the savings accounts of its premium customers.