Call conversions
Question
You are given the following tables, containing information about phone calls that a company receives as well as the company's sales.
all_sales
date | order_id | customer_id | order_source | phone_call_id | order_total | num_items |
---|---|---|---|---|---|---|
2019-12-20 | 00001 | 0001 | online | 0 | 50 | 1 |
2019-12-20 | 00002 | 0002 | phone | 4282 | 100 | 2 |
2019-12-20 | 00003 | 0003 | affiliate | 0 | 200 | 1 |
2019-12-20 | 00004 | 0004 | online | 0 | 100 | 2 |
2019-12-20 | 00005 | 0004 | phone | 4285 | 350 | 2 |
... | ... | ... | ... | ... | ... | ... |
call_info
date | employee_id | phone_call_id | order_id | call_length_sec |
---|---|---|---|---|
2019-12-20 | 31331 | 4282 | 00002 | 303 |
2019-12-20 | 34611 | 4285 | 00005 | 202 |
2019-12-20 | 49760 | 4286 | 0 | 155 |
2019-12-20 | 26583 | 4287 | 0 | 130 |
2019-12-20 | 20267 | 4288 | 0 | 190 |
... | ... | ... | ... | ... |
Using the tables above, write a SQL query to calculate the following metrics, split by week:
- percent of sales from calls
- percent of calls that made a purchase
- number of calls that purchase
- average call time for calls that purchase
- average call time for the week
Note that you should be able to write a full SQL query for this question just given the table schemas above.