The Question
SQLDaily Odd and Even Sensor Measurement Totals
Given a table
measurements containing measurement_id, measurement_value, and measurement_time, calculate the daily sum of values based on their chronological order within each day. A measurement is 'odd-numbered' if it is the 1st, 3rd, or 5th recorded event of that day, and 'even-numbered' if it is the 2nd, 4th, or 6th. Your output should contain the date, the total sum for odd-numbered measurements, and the total sum for even-numbered measurements for each day represented in the dataset.PostgreSQL
Window Function
CTE
Conditional Aggregation
Type Casting