From bce874cc098e77c441bdda15b8a397efd505ac27 Mon Sep 17 00:00:00 2001
From: alex <alex@pdp7.net>
Date: Thu, 28 Dec 2023 11:05:54 +0100
Subject: Average dose by week, not by administration

---
 weight/schema.sql | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'weight/schema.sql')

diff --git a/weight/schema.sql b/weight/schema.sql
index 07b08bb1..c057aefb 100644
--- a/weight/schema.sql
+++ b/weight/schema.sql
@@ -83,7 +83,7 @@ create view reporting.weekly_medication as (
 	    from   weight.pressure_medication
        )
 select    week.week,
-          avg(dose_mg) as average_daily_dose
+          sum(dose_mg)/7 as average_daily_dose
 from      generate_series((select min_week from limits), (select max_week from limits), '7 days') as week
 left join weight.pressure_medication on date_trunc('week', week.week) = date_trunc('week', pressure_medication.taken_at)
 group by  week.week order by week.week);
-- 
cgit v1.2.3

