Airbnb's marketing team wants to credit each user's acquisition to the channel of their first booking. A user's first booking is the one with the earliest booking_date; if a user made several bookings on that date, the one with the lowest booking_id is first. pct_of_users is the share of all users who have made a booking, times 100. Write an SQL query that returns channel, first_bookings (the number of users whose first booking came through that channel) and pct_of_users rounded to 2 decimal places. Order the results by first_bookings descending, then channel ascending.
Loading…
Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.
Ask questions, share alternate queries, and explore solutions
Your recent query executions and answer checks
This will insert the verified MySQL solution into your editor so you can study how each clause transforms the table.