Number Of Custom Email Labels

#Google

Find the number of occurrences of custom email labels for each user receiving an email. Output the receiver user id, label, and the corresponding number of occurrences.

table name: google_gmail_emails


table name: google_gmail_labels


Solution:

select e.to_user,
l.label,
count(*) as cnt from google_gmail_emails as e
join google_gmail_labels as l
on e.id= l.email_id
group by e.to_user,l.label
having l.label like '%custom%'

Output (Few Records):

SQL Script


Comments (0)