Files
ems/db/routines/R__fn_site_effective_prices_day_prague.sql
Dusan Vojacek 93f883f5e0
Some checks failed
CI and deploy / migration-check (push) Successful in 5s
CI and deploy / deploy (push) Failing after 20s
sql first refactor
2026-04-19 20:02:20 +02:00

29 lines
683 B
SQL

create or replace function ems.fn_site_effective_prices_day_prague(
p_site_id int,
p_day date
)
returns jsonb
language sql
stable
as $fn$
select coalesce(
jsonb_agg(u.j order by u.interval_start),
'[]'::jsonb
)
from (
select
t.interval_start,
to_jsonb(t) as j
from (
select v.*
from ems.vw_site_effective_price v
where v.site_id = p_site_id
and (v.interval_start at time zone 'Europe/Prague')::date = p_day
order by v.interval_start
) t
) u;
$fn$;
comment on function ems.fn_site_effective_prices_day_prague(int, date) is
'Efektivní ceny pro kalendářní den v TZ Praha jako pole JSON řádků view.';