oracle - Select 10th working day from my calendar table -


i have table there 2 columns date , holiday_flag.

date                    holiday_flag 01-jul-2015 00.00.00    n 02-jul-2015 00.00.00    n 03-jul-2015 00.00.00    y 04-jul-2015 00.00.00    y  05-jul-2015 00.00.00    y 06-jul-2015 00.00.00    n 07-jul-2015 00.00.00    n 08-jul-2015 00.00.00    n 09-jul-2015 00.00.00    n 10-jul-2015 00.00.00    n 11-jul-2015 00.00.00    y 12-jul-2015 00.00.00    y 13-jul-2015 00.00.00    n 14-jul-2015 00.00.00    n 

i want provide required date in condition , date of next 5th working day.

example: input  01-jul-2015 00.00.00 output 09-jul-2015 00.00.00 

here have done far

select b.date + 5 calendar b b.date = '01-jul-2015 00.00.00' , b.holiday_flag not null; 

i know doesn't work

one of ways use analytical function lead():

sqlfiddle demo

select d5    (     select cal_date, lead(cal_date, 5) on (order cal_date) d5       calendar holiday_flag='n')   cal_date = date '2015-07-01' 

Comments