Table Schema
Inspect
Table
| Column | Type |
|---|---|
| email_id | integer |
| sender_id | integer |
| sent_date | date |
Find users who sent more than 5 emails in a single day.
Table Schema
| Column | Type |
|---|---|
| email_id | integer |
| sender_id | integer |
| sent_date | date |
Sample Data
| email_id | sender_id | sent_date |
|---|---|---|
| 1 | 101 | 2024-01-01 |
| 2 | 101 | 2024-01-01 |
| 3 | 101 | 2024-01-01 |
| 4 | 101 | 2024-01-01 |
| 5 | 101 | 2024-01-01 |
| 6 | 101 | 2024-01-01 |
| 7 | 102 | 2024-01-02 |
| 8 | 103 | 2024-01-02 |
| sender_id |
|---|
| 101 |
SQL Editor
| sender_id |
|---|
| 101 |
Hints
Solution
Solution is locked until you decide to reveal it. Try the editor first, then open this when you want the reference answer.
SELECT DISTINCT sender_id FROM emails GROUP BY sender_id, sent_date HAVING COUNT(*) > 5;
Explanation
Create daily sender groups.
Use COUNT(*) for emails sent.
Keep only groups above 5 emails.
Related Questions