Write SQL and Python, run instantly in your browser, and track your progress.
You are a Product Analyst at LinkedIn. The Content team wants to identify each user's most recent posts. Rank each user's posts by created_at date, where rank 1 is the most recent post for that user.
| Column Name | Type |
|---|---|
| post_id | int64 |
| user_id | int64 |
| content_type | object |
| created_at | object |
You are a Product Analyst at LinkedIn. The Content team wants to identify each user's most recent posts. Rank each user's posts by created_at date, where rank 1 is the most recent post for that user.
| Column Name | Type |
|---|---|
| post_id | int64 |
| user_id | int64 |
| content_type | object |
| created_at | object |
| status | object |
| status | object |
| post_id | user_id | content_type | created_at | status |
|---|---|---|---|---|
| 1 | 101 | text | 2025-01-15 | published |
| 2 | 102 | image | 2025-01-16 | published |
| post_id | user_id | content_type | created_at | status |
|---|---|---|---|---|
| 1 | 101 | text | 2025-01-15 | published |
| 2 | 102 | image | 2025-01-16 | published |
| post_id | user_id | created_at | post_rank |
|---|---|---|---|
| 3 | 1 | 2025-06-02 | 1 |
| 1 | 1 | 2025-05-28 | 2 |
| 2 | 1 | 2025-04-20 | 3 |
| 5 | 2 | 2025-08-04 | 1 |
| post_id | user_id | created_at | post_rank |
|---|---|---|---|
| 3 | 1 | 2025-06-02 | 1 |
| 1 | 1 | 2025-05-28 | 2 |
| 2 | 1 | 2025-04-20 | 3 |
| 5 | 2 | 2025-08-04 | 1 |
Showing first 5 of 230 rows.
Showing first 5 of 230 rows.
1. Data Selection:
2. Window Function:
3. Output:
1. Data Selection:
2. Window Function:
3. Output:
| 3 |
| 3 |
| 101 |
| 101 |
| image |
| image |
| 2025-01-17 |
| 2025-01-17 |
| published |
| published |
| 4 | 101 | text | 2025-01-18 | published |
| 4 | 101 | text | 2025-01-18 | published |
| 5 | 102 | video | 2025-01-14 | published |
| 5 | 102 | video | 2025-01-14 | published |
| 4 | 2 | 2025-07-19 | 2 |
| 4 | 2 | 2025-07-19 | 2 |