My inital code was
"SELECT
UNNEST(ARRAY['Zone 0', 'Zone 1', 'Zone 2', 'Zone 3', 'Zone 4', 'Zone 5']) AS Zone,
UNNEST(ARRAY[
SUM(distance_zone_0),
SUM(distance_zone_1),
SUM(distance_zone_2),
SUM(distance_zone_3),
SUM(distance_zone_4),
SUM(distance_zone_5)
]) AS Total
FROM public.workout_data
WHERE user_id = {{user_id}}
AND workout_time >= {{user_start_date}}
AND workout_time < {{user_end_date}};"
And it worked just fine trying to change it to a field varible range however has been a struggle.
SELECT
UNNEST(ARRAY['Zone 0', 'Zone 1', 'Zone 2', 'Zone 3', 'Zone 4', 'Zone 5']) AS Zone,
UNNEST(ARRAY[
SUM(distance_zone_0),
SUM(distance_zone_1),
SUM(distance_zone_2),
SUM(distance_zone_3),
SUM(distance_zone_4),
SUM(distance_zone_5)
]) AS Total
FROM public.workout_data
WHERE user_id = {{user_id}}
AND workout_time {{date_range}};
it throws error "ERROR: syntax error at or near ""public"" Position: 505"
With simpler querys this date range worked fine.