SQL
Lab
Google Gmail Interview Question 06

Email
Activity

Find users who sent more than 5 emails in a single day.

Table Schema

Inspect
Table

interactive
ColumnType
email_idinteger
sender_idinteger
sent_datedate

Sample Data

Input
Output

Sample Input: emails
email_idsender_idsent_date
11012024-01-01
21012024-01-01
31012024-01-01
41012024-01-01
51012024-01-01
61012024-01-01
71022024-01-02
81032024-01-02
Expected Output
sender_id
101

SQL Editor

Run
Query

postgresql
Waiting for query

sender_id
101

Hints

Unlock
Clues

Hint 01: Group by sender and day.
Hint 02: Count emails in each sender-day group.
Hint 03: Return senders whose daily count is greater than 5.

Solution

Locked
Answer

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

Step By
Step

01

Create daily sender groups.

02

Use COUNT(*) for emails sent.

03

Keep only groups above 5 emails.

Related Questions

Keep
Solving