SQL
All Top 50 SQL Interview Questions#2
Filter High-Value Transactions in Price Ranges in SQL
EasyFlipkartInterview Question #2
Asked at FlipkartGiven a `transactions` table, write a SQL query to select all transactions with an `amount` between $500 and $5,000 (inclusive), excluding transactions marked with `payment_method = 'COD'`. Sort results by `amount` descending.
Input Table: transactions
4 rows preview| txn_id | customer_id | amount | payment_method | created_at |
|---|---|---|---|---|
| T1 | 201 | 450 | UPI | 2026-01-01 |
| T2 | 202 | 1200.5 | CREDIT | 2026-01-02 |
| T3 | 203 | 5000 | COD | 2026-01-03 |
| T4 | 204 | 3400 | NETBANKING | 2026-01-04 |
Expected Output Structure2 rows
| txn_id | customer_id | amount | payment_method |
|---|---|---|---|
| T4 | 204 | 3400 | NETBANKING |
| T2 | 202 | 1200.5 | CREDIT |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
PostgreSQL 15
Ready to execute
Click "Run Query" or press Ctrl + Enter to test your query.
Output will be verified against the test dataset.