Odd and Even Sensor Readings
Problem
**[Asked at Google]**
Industrial sensors emit readings throughout the day. For each calendar day,
readings are numbered in time order: 1st, 2nd, 3rd, … The data team wants:
- Sum of readings at **odd positions** (1st, 3rd, 5th, …)
- Sum of readings at **even positions** (2nd, 4th, 6th, …)
Return `reading_day`, `odd_sum`, `even_sum`, ordered by reading_day.
Tables
Example rows — the live problem includes the full dataset.
sensor_readings
| reading_id | value | recorded_at |
|---|
Expected output
Your answer should return 2 rows with the columns reading_day, odd_sum, even_sum.
Starter code (SQL)
SELECT *
FROM sensor_readings;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock