Your question is SQL Query Review. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Review this SQL query and table definition for Mercury and tell me what performance issues, security vulnerabilities, or anti-patterns you see.
Assess the query structure, parameter handling, indexing needs, authorization boundaries, and maintainability. Provide a corrected executable query using representative constant values rather than driver placeholders.
101 during January 2026.account_id, account_name, payment_id, amount, currency, and created_at.created_at descending, then payment_id descending.| Column | Type | Description |
|---|---|---|
| account_idPK | INTEGER | Unique Mercury account identifier |
| account_name | VARCHAR(120) | Display name for the account |
| Column | Type | Description |
|---|---|---|
| payment_idPK | BIGINT | Unique payment identifier |
| account_id | INTEGER | Account receiving or sending the payment |
| amount | NUMERIC(14,2) | Payment amount in the stated currency |
| currency | VARCHAR(3) | ISO currency code |
| status | VARCHAR(20) | Payment processing status |
| created_at | TIMESTAMPTZ | Payment creation timestamp |