Your question is SQL Top 10 Users. 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.
bet365 wants to identify its highest-value users based on settled stake transactions. Write a PostgreSQL query that ranks users by the total value of their qualifying transactions.
status = 'settled' and transaction_type = 'stake'.SUM.users table so the output includes the user's name.user_id as a deterministic tie-breaker.| Column | Type | Description |
|---|---|---|
| user_idPK | INTEGER | Unique bet365 user identifier |
| username | VARCHAR(80) | User display name |
| country_code | CHAR(2) | User registration country |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INTEGER | Unique transaction identifier |
| user_id | INTEGER | Associated user identifier |
| transaction_type | VARCHAR(20) | Transaction category |
| status | VARCHAR(20) | Transaction processing status |
| amount | NUMERIC(12,2) | Transaction amount |
| transaction_timestamp | TIMESTAMP | Transaction recording timestamp |