select max(cal_day) as the_day
from (
select cal_day
from calendar
where cal_day > '20180103'
and business_day = true
order by cal_day
limit 4
) bd;
the_day
2018-01-10
…
hidden batch(es)
select cal_day
from (select cal_day,
row_number() over (order by cal_day) rn
from calendar
where cal_day > '20180103'
and business_day = true
limit 4) bd
where rn = 4;
cal_day
2018-01-10
…
hidden batch(es)
create or replace function add_business_day(from_date date, num_days int)
returns date
as $fbd$
select max(cal_day) as the_day
from (select cal_day
from calendar
where cal_day > $1
and business_day = true
order by cal_day
limit $2) bd;
$fbd$ language sql;
✓
hidden batch(es)
create or replace function add_business_day2(from_date date, num_days int)
returns date
as $fbd$
select cal_day
from (select cal_day,
row_number() over (order by cal_day) rn
from calendar
where cal_day > $1
and business_day = true
limit $2) bd
where rn = $2;
$fbd$ language sql;