Last active
March 14, 2018 15:30
-
-
Save dmeehan1968/3fdc92d7a9bb0f8efa36ffb17b3742b2 to your computer and use it in GitHub Desktop.
Combine Heart Rate and Step in MySQL from HealthKit data export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select STR_TO_DATE(CONCAT(H.date, ' ', H.time), '%d/%m/%Y %H:%i') as datetime, H.min, H.max, coalesce(S.steps,0) as steps from heartrate H | |
left join steps S on | |
(H.date = S.date or H.date is null and S.date is null) | |
and | |
(H.time = S.time or H.time is null and S.time is null) | |
order by H.date, H.time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
STR_TO_DATE(CONCAT(H.date, ' ', H.time), '%d/%m/%Y %H:%i') as datetime, | |
H.min, | |
H.max, | |
coalesce(S.steps,0) as steps | |
from heartrate H | |
left join steps S on | |
(H.date = S.date or H.date is null and S.date is null) | |
and | |
(H.time = S.time or H.time is null and S.time is null) | |
group by date(datetime) | |
having hour(datetime) >= 0 and hour(datetime) <= 7 | |
order by datetime | |
limit 10000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment