-- adding four bussines days to 03/01/2018
select max(bday) as the_day
from (
select *
from bd
where bday > '20180103'
limit 4
) bd;
the_day
2018-01-10
…
hidden batch(es)
select bday
from (select bday,
row_number() over (order by bday) rn
from bd
where bday > '20180103') bd
where rn = 4;
bday
2018-01-10
…
hidden batch(es)
create or replace function add_bussines_day(bday date, num_days int)
returns date
as $fbd$
select max(bday) as the_day
from (select *
from bd
where bday > $1
limit $2
) bd;
$fbd$ language sql;