Given a table of sensor calibration events and a table of user sessions at Hinge health, write a query to find the average time elapsed between a sensor calibration and the start of a session. Match events by user and sensor, using the most recent calibration at or before each session. Exclude sessions without a qualifying calibration.
average_elapsed_minutes, rounded to two decimal places.| Column | Type | Description |
|---|---|---|
| calibration_idPK | INT | Unique calibration event identifier |
| user_id | INT | User associated with the calibration |
| sensor_id | VARCHAR(20) | Sensor associated with the calibration |
| calibrated_at | TIMESTAMPTZ | Time when calibration completed |
| Column | Type | Description |
|---|---|---|
| session_idPK | INT | Unique session identifier |
| user_id | INT | User associated with the session |
| sensor_id | VARCHAR(20) | Sensor used during the session |
| session_started_at | TIMESTAMPTZ | Session start time |