Interview Query

Download Facts

4
Have you seen this question before?

Given two tables: accounts, and downloads, find the average number of downloads for free vs paying accounts, broken down by day.

Note: You only need to consider accounts that have had at least one download before when calculating the average.

Note: round average_downloads to 2 decimal places.

Example:

Input:

accounts table

Column Type
account_id INTEGER
paying_customer BOOLEAN

downloads table

column type
account_id INTEGER
download_date DATETIME
downloads INTEGER

Output:

Column Type
download_date DATETIME
paying_customer BOOLEAN
average_downloads FLOAT
Next question: Over-Budget Projects
.....
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query