← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Senior

Senior
May 2026

Summary

Meta data engineer technical screen, just one SQL problem but it had enough layers to keep me busy for a while. The car rental utilization question looked straightforward on the surface but the edge cases around overlapping intervals and NULL dropoff timestamps slowed me down more than I expected.

Questions Asked (1)

Q1

Given tables for users, locations, cars, and rentals, write a SQL query that computes for each city and car size combination: the number of distinct cars rented on a specific date, the total active inventory for that city and car size, and the utilization rate as a decimal. Handle the case where a car has not yet been returned (NULL dropoff) and avoid dividing by zero.

Data ModelingProduct Analytics & MetricsTechnical Trade-offs
Author's notes

The join structure wasn't the hard part.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and assumptions, then break the problem into two parts: computing distinct cars rented per city and car size on the given date, and computing total active inventory per city and car size. Use conditional aggregation and handle NULL dropoff by treating it as still rented, and use NULLIF or CASE to avoid division by zero when calculating utilization rate.

Pro tip: Mention that you would validate the query with edge cases like no rentals or no inventory, and consider indexing on rental date and car size for performance. Also, clarify whether 'active inventory' means cars available for rent or total cars in the fleet, as this affects the denominator.

1. Clarify schema and assumptions

Ask about table structures, column names, and what 'active inventory' means. Confirm that a rental is active on the date if pickup_date <= date AND (dropoff_date IS NULL OR dropoff_date > date).

2. Compute distinct cars rented

Write a subquery that selects city, car_size, and counts distinct car_id from rentals joined with cars and locations, filtering for the specific date and active rentals.

3. Compute total active inventory

Write another subquery that counts total cars per city and car size from the cars and locations tables, assuming all cars are part of the inventory.

4. Combine and calculate utilization rate

Join the two subqueries on city and car_size, and compute utilization as rented_count / NULLIF(total_inventory, 0) to avoid division by zero.

5. Handle edge cases and finalize

Use COALESCE to handle NULLs from left joins, and ensure the query returns 0 for utilization when inventory is zero. Consider performance implications and indexing.

Key Points to Mention

  • Handling NULL dropoff_date to indicate an ongoing rental
  • Using COUNT(DISTINCT car_id) for distinct cars rented
  • Avoiding division by zero with NULLIF or CASE
  • Clarifying the definition of 'active inventory' (e.g., all cars vs. available cars)
  • Using conditional aggregation or subqueries to combine metrics
  • Considering indexing on rental date and car size for performance

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.