Describe how you would use window functions in SQL.
Use the supplied players and purchases tables to demonstrate the answer. Calculate completed purchase spend for active players and assign ranks, including players with no completed purchases.
player_name, total_spend, and spend_ranktotal_spend descending, then player_id ascending| Column | Type | Description |
|---|---|---|
| player_idPK | INT | Unique player identifier |
| player_name | VARCHAR(100) | Player display name |
| is_active | BOOLEAN | Whether the player is currently active |
| Column | Type | Description |
|---|---|---|
| purchase_idPK | INT | Unique purchase identifier |
| player_id | INT | Player associated with the purchase |
| amount | DECIMAL(10,2) | Purchase amount |
| status | VARCHAR(20) | Purchase state |