Your question is SQL for Third-Last Sale. 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.
SailPoint Technologies wants to identify person records in its identity data whose sale amount exceeds the amount of the third most recent sale. Write a PostgreSQL query that returns qualifying person IDs.
The third most recent sale is determined by sold_at DESC. Use sale_id DESC as a deterministic tie-breaker when timestamps are equal.
person_id with at least one sale amount greater than that amount.NULL sale amounts through the comparison and return IDs in ascending order without duplicates.| Column | Type | Description |
|---|---|---|
| person_idPK | INTEGER | Unique person identifier |
| person_name | VARCHAR(100) | Person display name |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INTEGER | Unique sale identifier |
| person_id | INTEGER | References persons.person_id |
| sale_amount | NUMERIC(12,2) | Sale value |
| sold_at | TIMESTAMP | Sale timestamp |