I have a parquet file named ah.parquet
.
It contains Apple Health data and has the following columns:
- type: Nullable(String)
- value: Nullable(String)
- start: Nullable(DateTime64(6))
- end: Nullable(DateTime64(6))
- created: Nullable(DateTime64(6))
Here is a list of all the types in the "type" column:
"HeartRate" "AppleStandHour" "SleepAnalysis" "RespiratoryRate" "EnvironmentalAudioExposure" "HeartRateVariabilitySDNN" "OxygenSaturation" "BasalEnergyBurned" "ActiveEnergyBurned" "DistanceWalkingRunning" "StepCount" "AppleExerciseTime" "AppleStandTime" "StairAscentSpeed" "FlightsClimbed" "WalkingDoubleSupportPercentage" "WalkingSpeed" "WalkingStepLength" "WalkingAsymmetryPercentage" "RestingHeartRate" "WalkingHeartRateAverage" "AppleSleepingWristTemperature" "StairDescentSpeed" "DistanceCycling" "AppleWalkingSteadiness" "HeadphoneAudioExposure" "BodyMass" "SixMinuteWalkTestDistance" "PhysicalEffort" "TimeInDaylight" "VO2Max" "HeartRateRecoveryOneMinute" "HighHeartRateEvent" "LowCardioFitnessEvent" "AudioExposureEvent" "MindfulSession" "Height" "DistanceSwimming" "SwimmingStrokeCount" "DietaryCaffeine" "HKDataTypeSleepDurationGoal" "RunningSpeed" "Fatigue" "RunningPower" "RunningVerticalOscillation" "RunningGroundContactTime" "RunningStrideLength"
SELECT SUM(toFloat64(value)) AS total_steps
FROM 'ah.parquet'
WHERE type = 'StepCount'
SELECT AVG(toFloat64(value)) AS average_heart_rate
FROM 'ah.parquet'
WHERE type = 'HeartRate'
SELECT SUM(toFloat64(value)) AS total_distance
FROM 'ah.parquet'
WHERE type = 'DistanceWalkingRunning' AND start >= '2021-01-01' AND start < '2022-01-01'
SELECT MAX(end) AS last_cycling_session
FROM 'ah.parquet'
WHERE type = 'DistanceCycling'
- Always answer only with an SQL query that answers the question.
- Only answer with SQL, no ``` demarcation. SQL only.