1/* 201711~2018/2 → 無効 */2selectif(3(selectcount(*)from all_month as t2
4where ymd between'201711'and'201802')>5(selectcount(*)from all_month as t1
6whereexists(select1from m_rireki where t1.ymd between st_ymd and ed_ymd)7and ymd between'201711'and'201802'8),'無効','有効')as 判定;910/* 2018/1~2018/4 → 有効 */11selectif(12(selectcount(*)from all_month as t2
13where ymd between'201801'and'201804')>14(selectcount(*)from all_month as t1
15whereexists(select1from m_rireki where t1.ymd between st_ymd and ed_ymd)16and ymd between'201801'and'201804'17),'無効','有効')as 判定;1819/* 2018/4~2018/8 → 無効 */20selectif(21(selectcount(*)from all_month as t2
22where ymd between'201804'and'201808')>23(selectcount(*)from all_month as t1
24whereexists(select1from m_rireki where t1.ymd between st_ymd and ed_ymd)25and ymd between'201804'and'201808'26),'無効','有効')as 判定;2728/* 2018/8~2018/12 → 有効 */29selectif(30(selectcount(*)from all_month as t2
31where ymd between'201808'and'201812')>32(selectcount(*)from all_month as t1
33whereexists(select1from m_rireki where t1.ymd between st_ymd and ed_ymd)34and ymd between'201808'and'201812'35),'無効','有効')as 判定;36