fix month yield

This commit is contained in:
2023-03-17 18:45:34 +01:00
parent 907790300e
commit b64fd0206c
2 changed files with 71 additions and 1 deletions

View File

@ -41,7 +41,7 @@ with
date_trunc('day', min(time)) as day
from pv_power_measurement_t
where
time between date_trunc('month', time) and now()
time between date_trunc('month', now()) and now()
),
first_value as (
select
@ -64,6 +64,9 @@ with
group by interval
)
select
(select day from first_day_in_month) as v1,
(select energy from first_value) as v2,
(select energy from last_value) as v3,
to_char((select day from first_day_in_month), 'Month') as period_value,
'Month' as period_name,
(select energy from last_value) - (select energy from first_value) as yield;