All tasks

Nearest Sensor Reading to Event

Expert

Google/IoT level task. **Condition:** For each sensor event, find the nearest temperature reading BEFORE this event. **Tables:** - sensor_events (event_id, sensor_id, event_type, event_time) - sensor_data (sensor_id, timestamp, reading) **Requirements:** 1. For each event, find the reading with the closest timestamp < event_time 2. If no reading exists — return NULL 3. Output event_id, event_time, nearest_reading, nearest_reading_time, time_diff_seconds **Hint:** Lateral join or

Category
Complex Joins
Estimated time
~35 min
Databases
PostgreSQLGreenplum
Tags
FAANGInterviewNearest MatchInequality JoinTime Seriesподзапросы

Sign in to solve

Start Solving