Explain the difference between window functions and joins in terms of performance and use cases.
Use the supplied PostgreSQL tables to support the explanation with a query that combines user activity and produces a per-user ranking. Discuss why the selected approach preserves row detail and how an equivalent join-based approach could affect performance.
team, user_name, activity_count, and activity_rankteam ascending with null teams last, then rank and user ID| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| user_name | VARCHAR(100) | User display name |
| team | VARCHAR(100) | User team |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique activity event identifier |
| user_id | INT | User associated with the event |
| event_type | VARCHAR(50) | Type of activity event |