Only status 'SUCCESS' transactions count. txn_type was typed by different services, so compare it case-insensitively and ignore surrounding spaces ('p2m ' is P2M). Return one row per month that has at least one successful transaction: month ('YYYY-MM'), p2p_amount, p2m_amount, bill_amount and total_amount (all successful transactions of any type, including other types such as RECHARGE). All amounts ROUND to 2 and 0 when there is nothing. Order by month.
| Column | Type |
|---|---|
| txn_id | INTEGER |
| txn_date | DATE |
| txn_type | TEXT |
| amount | REAL |
| status | TEXT |
| txn_id | txn_date | txn_type | amount | status |
|---|---|---|---|---|
| 1 | 2026-01-03 | P2P | 500 | SUCCESS |
| 2 | 2026-01-05 | P2M | 250 | SUCCESS |
| 3 | 2026-01-09 | BILL | 1200 | SUCCESS |
| 4 | 2026-01-15 | P2P | 300 | FAILED |
| 5 | 2026-02-02 | P2M | 99.5 | SUCCESS |
| 6 | 2026-02-10 | P2M | 400 | SUCCESS |
| 7 | 2026-02-18 | P2P | 150 | SUCCESS |
| 8 | 2026-02-20 | BILL | 600 | PENDING |
| month | p2p_amount | p2m_amount | bill_amount | total_amount |
|---|---|---|---|---|
| 2026-01 | 500 | 250 | 1200 | 1950 |
| 2026-02 | 150 | 499.5 | 0 | 649.5 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Top Suppliers' Share of Category GMV · Parse Error Logs by Module ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.