Interview Query

Page Recommendations

0
Have you seen this question before?

Write a query to get the percentage of recommendations for each page by users in the same postal code as the page. 

Note: A page can sponsor multiple postal codes.

Example:

Input:

page_sponsorships table

Column Type
page_id INTEGER
postal_code VARCHAR
price FLOAT

recommendations table 

Column Type
user_id INTEGER
page_id INTEGER

users table

Column Type
id INTEGER
postal_code VARCHAR

Output:

Column Type
page INTEGER
postal_code VARCHAR
percentage FLOAT
Next question: Fake Ad Prevalence
.....
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query