๐Ÿ“š 100 DAYS SQL

CODING CHALLENGE

DAY 20
Master SQL One Problem at a Time

โœจ Daily SQL Problems
โœจ Real-World Scenarios
โœจ Complete Solutions
โœจ Interview Ready

๐Ÿจ Hotel Booking & Occupancy Trends

You work at Grand Plaza Hotel with 50 rooms. Management wants to analyze booking patterns to optimize pricing and staffing.

Table 1: bookings

booking_id guest_id room_id check_in_date check_out_date
B001 G101R2012024-01-052024-01-08
b002G102 r305 06/01/20242024-01-09
B003 g103 R2012024/01/1012-01-2024
B004G104R1022024-01-07NULL

Table 2: rooms

room_id room_type price_per_night floor_number
R201Deluxe150.002
r305SUITE250.003
R102standard100.001
R405Suite250.004

Table 3: guests

guest_id guest_name country
G101john smithUSA
g102 MARIA GARCIAspain
G103David ChenChina
G104 sarah johnson CANADA

Download full dataset above for complete data (25 rows per table)

๐Ÿ“‹ Challenge Requirements

Analyze hotel booking data to identify trends, calculate revenue, and validate guest information.

๐Ÿงน Data Cleaning:
  • Standardize IDs: uppercase, trim
  • Clean names: proper case, trim
  • Standardize dates: all to YYYY-MM-DD
  • Handle NULL check_out_date
  • Standardize room_type: proper case
  • Standardize country: proper case
๐Ÿ”— JOINs & Enrichment:
  • JOIN bookings โ†’ rooms
  • JOIN bookings โ†’ guests
  • Calculate nights_stayed
  • Calculate total_cost per booking
  • Group by room_type for revenue
  • Filter international guests
โš ๏ธ Analytics & Validation:
  • Count bookings per room type
  • Calculate total revenue per type
  • Identify highest spending guests
  • Find incomplete bookings
  • Calculate average stay duration
  • Segment by guest country

๐Ÿ’ก INNER JOIN, DATEDIFF, CASE, GROUP BY, SUM, ORDER BY!

๐ŸŽ‰ Ready to Solve?

Download the PDF for complete solution with hints!

๐Ÿ’ช Keep Practicing!

Master hotel analytics
Build revenue tracking systems
Analyze booking trends with SQL

Day 21 coming tomorrow!

Rahul Kanche โ€” exploring data, decoding clarity!