Interview Query

Listing Bookings Aggregation

Start Timer

0:00:00

Upvote
3
Downvote
Save question
Mark as completed
View comments (15)
Next question

Let’s say we have a table representing vacation bookings. Write a query that returns columns representing the total number of bookings in the last 90 days, last 365 days, and overall.

Note: You may assume that today is the 1st of January 2022.

Example:

Input:

bookings table

Column Type
reservation_id INTEGER
guest_id INTEGER
check_in_date DATE
check_out_date DATE

Output:

Column Type
num_bookings_last90d INTEGER
num_bookings_last365d INTEGER
num_bookings_total INTEGER
.
.
.
.
.


Comments

Loading comments..