Data describes Id, Activity Hour and StepTotal.
ActivityHour is defined in the format YY-MM-DD HH:MM:SS.
I am looking to obtain entries between 2016-04-12 AND 2016-05-12
where the time is between 08:00:00 UTC AND 15:00:00 UTC
and the StepTotal is less than 50.
I want the result to be ordered by Id.
I thought I should use substring to separate date and time - but I am really going wrong somewhere.
Here's what I have:
SELECT Id, ActivityHour, StepTotal,
SUBSTR(ActivityHour, 11, 23) AS Time,
FROM `dataset` AS Time
WHERE ActivityHour BETWEEN '2016-04-12' AND '2016-05-12'
AND Time BETWEEN '08:00:00 UTC' AND '15:00:00 UTC'
AND StepTotal < 50
ORDER BY Id, ActivityHour
Are you labeling your table
Timeand then using it to query the actual time between your timepoints? Just because you call it time it doesn't make it time.Maybe you can use extract function? Maybe try