I have a database with columns timestamp and value. Logging is done periodically. Now I want to do daily aggregation. Have done it this way:
SELECT
strftime("%Y-%m-%d", timestamp) AS "new_timestamp",
AVG(value) as value_avg,
MIN(value) as value_min,
MAX(value) as value_max,
COUNT(*) as num_samples,
/* ... something for when max and min value occurs */
FROM my_table
GROUP BY "new_timestamp"
Q: How do I get timestamp/time when MIN or MAX has occurred in that day?
EDIT: In my specific case, if there are multiple min or max values it doesn't matter which one should be picked. I'm using SQLite.