I run this bit of code in SQL and would like to get data for a certain duration of time. Here 40min every hour, could be 10min for example; The idea is to get snapshots of shorter timeframe It works with 1 interval but when you go above like here, it doesn't work anymore
The query output : 'There is no data to display'.
SELECT *
FROM `xxxx.yyyy.data`
WHERE
executedAt > "2022-05-18 12:00:00"
AND executedAt < "2022-05-18 12:40:00"
AND executedAt > "2022-05-18 13:00:00"
AND executedAt < "2022-05-18 13:40:00"
AND executedAt > "2022-05-18 14:00:00"
AND executedAt < "2022-05-18 14:40:00"
Thank you for your help
CodePudding user response:
if i understood you this will work
SELECT *
FROM `xxxx.yyyy.data`
WHERE
(executedAt > '2022-05-18 12:00:00' AND executedAt < '2022-05-18 12:40:00') OR
(executedAt > '2022-05-18 13:00:00' AND executedAt < '2022-05-18 13:40:00') OR
(executedAt > '2022-05-18 14:00:00' AND executedAt < '2022-05-18 14:40:00')