sql first refactor
This commit is contained in:
28
db/routines/R__fn_site_effective_prices_day_prague.sql
Normal file
28
db/routines/R__fn_site_effective_prices_day_prague.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
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.';
|
||||
Reference in New Issue
Block a user