Practice Interview Questions
| Question | Status |
|---|---|
Google's marketing team is making a Superbowl commercial and needs a simple statistic to put on their TV ad: the median number of searches a person made last year.
However, at Google's scale, querying the 2 trillion searches is too costly. Luckily, you have access to the summary table which tells you the number of searches made last year and how many Google users fall into that bucket.
Write a query to report the median of searches made by a user. Round the median to 1 decimal point.
HINT: Think about expanding the search_frequency table to have something like [1, 1, 2, 2, 3, 3, 3, 4]
search_frequency table:
| Column Name | Description |
|---|---|
| searches | The number of searches |
| num_users | Count of users with that search frequency |
| median |
|---|
| 11.5 |
Google's marketing team is making a Superbowl commercial and needs a simple statistic to put on their TV ad: the median number of searches a person made last year.
However, at Google's scale, querying the 2 trillion searches is too costly. Luckily, you have access to the summary table which tells you the number of searches made last year and how many Google users fall into that bucket.
Write a query to report the median of searches made by a user. Round the median to 1 decimal point.
HINT: Think about expanding the search_frequency table to have something like [1, 1, 2, 2, 3, 3, 3, 4]
search_frequency table:
| Column Name | Description |
|---|---|
| searches | The number of searches |
| num_users | Count of users with that search frequency |
| median |
|---|
| 11.5 |