Active Subscription Order
Step 2: for each active subscription with status = 'active', assign its sequence number within its user_id: the earliest started_at gets 1, and a tie uses the smaller id first. Return id, user_id, and rn, sorted by user_id, then rn.
Expected output sample
This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables.
| id | rn | user_id |
|---|---|---|
| 300 | 1 | 1 |
| 301 | 2 | 1 |
| 302 | 1 | 2 |
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in