Bank-Wise Share of UPI Transactions Stuck in Pending
Last updated: November 29, 2026
Quick Overview
Using a UPI transactions table, write SQL that reports for each payer bank how many transactions from the last 24 hours are still PENDING more than 30 minutes after creation, and what percentage of that bank's volume they represent.
PhonePe
November 29, 20260
0
0 solved
Using a UPI transactions table, write SQL that reports for each payer bank how many transactions from the last 24 hours are still PENDING more than 30 minutes after creation, and what percentage of that bank's volume they represent.
When a remitter bank's systems degrade, PhonePe sees UPI payments pile up in pending, and ops teams need a bank-level view quickly to route users or show warnings. The interviewer checks clean SQL with a correct denominator, explicit time windows and awareness of what pending means in UPI.
What the Interviewer Expects
- Clarify the schema, status values and the as-of time
- Use the same window for numerator and denominator
- Exclude very recent transactions that are legitimately still in flight
- Use a LEFT JOIN so banks with zero stuck transactions still appear
- Validate with a tiny hand-made dataset
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you turn this into a streaming alert that fires within a minute?
- Pending rates differ by hour of day. How would you set a per-bank baseline instead of a fixed threshold?
- How do you treat transactions that went PENDING and later became DEEMED or REVERSED?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
Table upi_txn(txn_id, payer_bank, created_at, status, ...). Status is one of SUCCESS, FAILED, PENDING (plus states like DEEMED or REVERSED depending on design). :as_of is the report time. 'Last 24...
Approach
Build two CTEs over the same window: stuck (still PENDING) and volume (all transactions per bank). LEFT JOIN stuck onto volume so every bank with traffic shows, including those at 0%. Sort by ...