Rolling Conversion
Start Timer
0:00:00
Let’s say we’re given a searches table with one row per hotel search. booked is true if the search ended in a booking.
Write a query to get the 7-day rolling conversion rate for Bangkok for every date from March 1 to March 10, 2026.
Note: The rate for a date is bookings divided by searches over that date and the 6 days before it. Some days have no searches at all and still need a row. Round to 4 decimal places.
Example:
Input:
searches table
| Column | Type |
|---|---|
search_id |
INTEGER |
city |
VARCHAR |
search_date |
DATE |
booked |
BOOLEAN |
Output:
| Column | Type |
|---|---|
date |
DATE |
conversion_rate |
FLOAT |
.
.
.
.
.
.
.
.
.
Comments