Customer support time in SQL
Question
Write a query to get the response time per email (id) sent to support@xyz.com. Do not include ids that did not receive a response from support@xyz.com. Assume each email thread has a unique subject. Keep in mind a thread may have multiple responses back-and-forth between support@xyz.com and another email address.
Table: email_log
id | subject | from | to | date |
---|---|---|---|---|
1 | Support 1 | customer1@abc.com | support@xyz.com | 2021-07-01 00:00:00 |
2 | Support 2 | customer2@abc.com | support@xyz.com | 2021-07-02 00:00:00 |
3 | Info 1 | customer4@abc.com | info@xyz.com | 2021-07-03 00:00:00 |
4 | General 2 | customer5@abc.com | questions@xyz.com | 2021-07-04 00:00:00 |
5 | Support 1 | support@xyz.com | customer1@abc.com | 2021-07-05 00:00:00 |
6 | Support 3 | customer3@abc.com | support@xyz.com | 2021-07-06 00:00:00 |
7 | Support 2 | support@xyz.com | customer2@abc.com | 2021-07-07 00:00:00 |
You can view/query this table in an interactive SQL fiddle here.