Lecture
Sort and Limit Recent Reservations
Your front desk team needs a quick view of the latest hotel check-ins to prepare for arrivals and manage room readiness.
You’ve been asked to extract the five most recent bookings based on their check-in dates.
To do this, you’ll combine two SQL tools:
ORDER BY— sorts results by dateLIMIT— restricts how many rows are returned
This approach is often used in dashboards, daily reports, and operational summaries.
Task
From the bookings table in the hotel_booking.sqlite database, display:
hotel_namecitycheck_in_date
Show only the five most recent bookings, sorted by check_in_date in descending order (newest first).
How to solve it
Write a SQL query in the editor that returns the 5 latest bookings.
Use ORDER BY check_in_date DESC to sort from newest to oldest, and add LIMIT 5 to keep only the most recent records.
Lessons in this chapter · Solve real-world problems with SQL.
- 1. Filter Bookings by Region
- 2. Sort and Limit Recent Reservations
- 3. Use Logical AND/OR to Filter Hotel Data
- 4. Count Transactions by Customer
- 5. Calculate Average Spending per Client
- 6. Filter Customers with High Transaction Totals
- 7. Join Flights with Passengers
- 8. List Passengers with No Reservations
- 9. Find Customers with High-Priced Ticket Purchases
- 10. Filter Events with Above-Average Ticket Sales
sqlQuiz
?
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help