[selectRecords] select '売掛金回収管理帳' as report_nm, (trunc((row_number()over(order by w.tok_cd,w.syori_ym)-1)/30)+1) as uri_row_kai, 'Page.'||(trunc((row_number()over(order by w.syori_ym)-1)/30)+1) as uri_row_kai_s, (case when (coalesce(mt.tok_nm,'') != '') then mt.tok_nm||'('||w.tok_cd||')'else ''end) as tok_nm_s, (case when(seikyu_ymd != '')then(to_char(to_date(seikyu_ymd, 'YYYYMMDD'), 'yyyy/mm/dd'))else('')end) as seikyu_ymd, '2018'||'年'||'10'||'月分管理帳' as syori_ym_s, case trim(to_char(mt.shime_dd,'00')) when '99' then '末' else trim(to_char(mt.shime_dd,'00')) end as shime_dd, mt.pay_m, case trim(to_char(mt.pay_d,'00')) when '99' then '末' else trim(to_char(mt.pay_d,'00')) end as pay_d, hn1.han_name || case trim(to_char(mt.pay_d,'00')) when '99' then '末' else trim(to_char(mt.pay_d,'00')) end || '日' as pay_md_s, mt.biko1, mt.tan_cd, mt.tori_cond, mt.zei_calc_kbn, mt.keisyo, mt.tok_rnm, w.* from ( select tok_cd , syori_ym , COALESCE(zen_zan,'0') as zen_zan , COALESCE(uri_zeinuki_gaku,'0') as uri_zeinuki_gaku , COALESCE(uri_zei_gaku,'0') as uri_zei_gaku , COALESCE(uri_zeikomi_gaku,'0') as uri_zeikomi_gaku , COALESCE(urihen_zeikomi_gaku,'0') as urihen_zeikomi_gaku , (COALESCE(uri_zeikomi_gaku,'0') - COALESCE(urihen_zeikomi_gaku,'0')) as zeikomi_gaku , COALESCE(nyukin_yotei_gaku,'0') as nyukin_yotei_gaku , COALESCE(nyukin_ymd,'0') as nyukin_ymd , COALESCE(nyukin_genkin,'0') as nyukin_genkin , COALESCE(nyukin_kogitte,'0') as nyukin_kogitte , COALESCE(nyukin_furikomi,'0') as nyukin_furikomi , COALESCE(nyukin_tegata,'0') as nyukin_tegata , COALESCE(nyukin_sousai,'0') as nyukin_sousai , COALESCE(nyukin_tesuryo,'0') as nyukin_tesuryo , COALESCE(nyukin_sonota,'0') as nyukin_sonota , (case when(nyukin_ymd_cash != '')then(to_char(to_date(nyukin_ymd_cash, 'YYYYMMDD'), 'yyyy/mm/dd'))else('')end) as nyukin_ymd_cash , (case when(nyukin_ymd_tegata != '')then(to_char(to_date(nyukin_ymd_tegata, 'YYYYMMDD'), 'yyyy/mm/dd'))else('')end) as nyukin_ymd_tegata from v_urikake_union ) w left join m_tokui mt on (w.tok_cd = mt.tok_cd) left join m_hanyo hn1 on (mt.pay_m::char = hn1.han_cd and hn1.mst_kbn = '10') where (('' = '&20') or (w.tok_cd >= '&20')) and (('' = '&21') or (w.tok_cd <= '&21')) and w.syori_ym >= TO_CHAR(TO_DATE('&18'||'&19', 'YYYYMM') - CAST('2 month' AS INTERVAL), 'YYYYMM') and w.syori_ym <= (TO_CHAR(&18,'FM9999')||'&19') order by w.tok_cd,w.syori_ym ; [selectRecords_old] select '売掛金回収管理帳' as report_nm, (trunc((row_number()over(order by w.tok_cd,w.kbn)-1)/24)+1) as uri_row_kai, 'Page.'||(trunc((row_number()over(order by w.tok_cd,w.kbn)-1)/24)+1) as uri_row_kai_s, (case when (coalesce(tok_nm,'') != '') then tok_nm||'('||tok_cd||')'else ''end) as tok_nm_s, (case when(seikyu_ymd != '')then(to_char(to_date(seikyu_ymd, 'YYYYMMDD'), 'yyyy/mm/dd'))else('')end) as seikyu_ymd, (case when(nyukin_yotei_ymd != '')then(to_char(to_date(nyukin_yotei_ymd, 'YYYYMMDD'), 'yyyy/mm/dd'))else('')end) as nyukin_yotei_ymd, (case when(nyukinbi_genkin != '')then(to_char(to_date(nyukinbi_genkin, 'YYYYMMDD'), 'yyyy/mm/dd'))else('')end) as nyukinbi_genkin, (case when(nyukinbi_tegata != '')then(to_char(to_date(nyukinbi_tegata, 'YYYYMMDD'), 'yyyy/mm/dd'))else('')end) as nyukinbi_tegata, (case when(mankibi != '')then(to_char(to_date(mankibi, 'YYYYMMDD'), 'yyyy/mm/dd'))else('')end) as mankibi, '2018'||'年'||'10'||'月分管理帳' as syori_ym_s, coalesce(furikomi,0) as furikomi, coalesce(genkin,0) as genkin, coalesce(kogitte,0) as kogitte, coalesce(tegata,0) as tegata, coalesce(sousai,0) as sousai, coalesce(tesuryo,0) + coalesce(tesuryo_add,0) as tesuryo, coalesce(sonota,0) + coalesce(sonota_add,0) as sonota, w.* from( select '1' as kbn, v.tok_cd as tok_cd, v.seikyu_ymd, v.zen_seikyu_zan as zen_seikyu_zan, v.nyukin_gaku as nyukin_gaku, v.kurikoshi_gaku as kurikoshi_gaku, v.zeinuki_gaku as zeinuki_gaku, v.zei_gaku as zei_gaku, v.zeikomi_gaku as zeikomi_gaku, v.seikyu_zan as seikyu_zan, v.nyukin_yotei_ymd, mt.tok_nm as tok_nm, -- mt.shime_dd, case trim(to_char(mt.shime_dd,'00')) when '99' then '末' else trim(to_char(mt.shime_dd,'00')) end as shime_dd, mt.pay_m, case trim(to_char(mt.pay_d,'00')) when '99' then '末' else trim(to_char(mt.pay_d,'00')) end as pay_d, hn1.han_name || case trim(to_char(mt.pay_d,'00')) when '99' then '末' else trim(to_char(mt.pay_d,'00')) end || '日' as pay_md_s, mt.biko1, mt.tan_cd, mt.tori_cond, mt.zei_calc_kbn, mt.keisyo, mt.tok_rnm, (select max(n.nyukin_ymd) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 != 'tegata' ) as nyukinbi_genkin, (select max(n.nyukin_ymd) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'tegata' ) as nyukinbi_tegata, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'furikomi' ) as furikomi, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'genkin' ) as genkin, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'kogitte' ) as kogitte, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'tegata' ) as tegata, (select max(n.tegata_ymd) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd ) as mankibi, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'sousai' ) as sousai, (select sum(n.total_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'tesuryo' ) as tesuryo, (select sum(n.tesuryo) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and COALESCE(h1.koumoku1,'') not in ('tesuryo', '') ) as tesuryo_add, (select sum(n.total_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) left join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and COALESCE(h1.koumoku1,'') = '' ) as sonota, (select sum(n.cyosei_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and COALESCE(h1.koumoku1,'') not in ('tesuryo', '') ) as sonota_add, '' as biko_a from t_urikake v inner join m_tokui mt on (v.tok_cd = mt.tok_cd) left join m_tanto tn on (tn.tan_cd = mt.tan_cd) left join m_hanyo hn1 on (mt.pay_m::char = hn1.han_cd and hn1.mst_kbn = '10') where 1=1 and v.del_flg= 0 and v.zeinuki_gaku <> 0 and (('' = '') or (tn.bu_cd = '')) and (('' = '') or (mt.cat_cd = '')) and (('' = '') or (tn.tan_cd >= '')) and (('' = '') or (tn.tan_cd <= '')) and (('' = '') or (mt.tok_cd >= '')) and (('' = '') or (mt.tok_cd <= '')) and (('' = ('2018'||'07')) or (substr(v.seikyu_ymd,1,6) =('2018'||'07'))) union all select '2' as kbn, v.tok_cd as tok_cd, v.seikyu_ymd, v.zen_seikyu_zan as zen_seikyu_zan, v.nyukin_gaku as nyukin_gaku, v.kurikoshi_gaku as kurikoshi_gaku, v.zeinuki_gaku as zeinuki_gaku, v.zei_gaku as zei_gaku, v.zeikomi_gaku as zeikomi_gaku, v.seikyu_zan as seikyu_zan, v.nyukin_yotei_ymd, mt.tok_nm as tok_nm, -- mt.shime_dd, case trim(to_char(mt.shime_dd,'00')) when '99' then '末' else trim(to_char(mt.shime_dd,'00')) end as shime_dd, mt.pay_m, case trim(to_char(mt.pay_d,'00')) when '99' then '末' else trim(to_char(mt.pay_d,'00')) end as pay_d, hn1.han_name || case trim(to_char(mt.pay_d,'00')) when '99' then '末' else trim(to_char(mt.pay_d,'00')) end || '日' as pay_md_s, mt.biko1, mt.tan_cd, mt.tori_cond, mt.zei_calc_kbn, mt.keisyo, mt.tok_rnm, (select max(n.nyukin_ymd) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 != 'tegata' ) as nyukinbi_genkin, (select max(n.nyukin_ymd) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'tegata' ) as nyukinbi_tegata, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'furikomi' ) as furikomi, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'genkin' ) as genkin, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'kogitte' ) as kogitte, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'tegata' ) as tegata, (select max(n.tegata_ymd) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd ) as mankibi, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'sousai' ) as sousai, (select sum(n.total_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'tesuryo' ) as tesuryo, (select sum(n.tesuryo) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and COALESCE(h1.koumoku1,'') not in ('tesuryo', '') ) as tesuryo_add, (select sum(n.total_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) left join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and COALESCE(h1.koumoku1,'') = '' ) as sonota, (select sum(n.cyosei_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and COALESCE(h1.koumoku1,'') not in ('tesuryo', '') ) as sonota_add, '' as biko_a from t_urikake v inner join m_tokui mt on (v.tok_cd = mt.tok_cd) left join m_tanto tn on (tn.tan_cd = mt.tan_cd) left join m_hanyo hn1 on (mt.pay_m::char = hn1.han_cd and hn1.mst_kbn = '10') where 1=1 and v.del_flg= 0 and v.zeinuki_gaku <> 0 and (('' = '') or (tn.bu_cd = '')) and (('' = '') or (mt.cat_cd = '')) and (('' = '') or (tn.tan_cd >= '')) and (('' = '') or (tn.tan_cd <= '')) and (('' = '') or (mt.tok_cd >= '')) and (('' = '') or (mt.tok_cd <= '')) and (('' = ('2018'||'08')) or (substr(v.seikyu_ymd,1,6) =('2018'||'08'))) union all select '3' as kbn, v.tok_cd as tok_cd, v.seikyu_ymd, v.zen_seikyu_zan as zen_seikyu_zan, v.nyukin_gaku as nyukin_gaku, v.kurikoshi_gaku as kurikoshi_gaku, v.zeinuki_gaku as zeinuki_gaku, v.zei_gaku as zei_gaku, v.zeikomi_gaku as zeikomi_gaku, v.seikyu_zan as seikyu_zan, v.nyukin_yotei_ymd, mt.tok_nm as tok_nm, -- mt.shime_dd, case trim(to_char(mt.shime_dd,'00')) when '99' then '末' else trim(to_char(mt.shime_dd,'00')) end as shime_dd, mt.pay_m, case trim(to_char(mt.pay_d,'00')) when '99' then '末' else trim(to_char(mt.pay_d,'00')) end as pay_d, hn1.han_name || case trim(to_char(mt.pay_d,'00')) when '99' then '末' else trim(to_char(mt.pay_d,'00')) end || '日' as pay_md_s, mt.biko1, mt.tan_cd, mt.tori_cond, mt.zei_calc_kbn, mt.keisyo, mt.tok_rnm, (select max(n.nyukin_ymd) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 != 'tegata' ) as nyukinbi_genkin, (select max(n.nyukin_ymd) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'tegata' ) as nyukinbi_tegata, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'furikomi' ) as furikomi, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'genkin' ) as genkin, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'kogitte' ) as kogitte, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'tegata' ) as tegata, (select max(n.tegata_ymd) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd ) as mankibi, (select sum(n.nyukin_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'sousai' ) as sousai, (select sum(n.total_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and h1.koumoku1 = 'tesuryo' ) as tesuryo, (select sum(n.tesuryo) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and COALESCE(h1.koumoku1,'') not in ('tesuryo', '') ) as tesuryo_add, (select sum(n.total_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) left join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and COALESCE(h1.koumoku1,'') = '' ) as sonota, (select sum(n.cyosei_gaku) from t_nyu_keshi k inner join t_nyukin n on (n.nyukin_no = k.nyukin_no) inner join m_hanyo h1 on (h1.mst_kbn = '13' and h1.han_cd = n.nyukin_kbn) where 1=1 and k.tok_cd = v.tok_cd and k.seikyu_ymd = v.seikyu_ymd and COALESCE(h1.koumoku1,'') not in ('tesuryo', '') ) as sonota_add, '' as biko_a from t_urikake v inner join m_tokui mt on (v.tok_cd = mt.tok_cd) left join m_tanto tn on (tn.tan_cd = mt.tan_cd) left join m_hanyo hn1 on (mt.pay_m::char = hn1.han_cd and hn1.mst_kbn = '10') where 1=1 and v.del_flg= 0 and v.zeinuki_gaku <> 0 and (('' = '') or (tn.bu_cd = '')) and (('' = '') or (mt.cat_cd = '')) and (('' = '') or (tn.tan_cd >= '')) and (('' = '') or (tn.tan_cd <= '')) and (('' = '') or (mt.tok_cd >= '')) and (('' = '') or (mt.tok_cd <= '')) and (('' = ('2018'||'09')) or (substr(v.seikyu_ymd,1,6) =('2018'||'09'))) )w order by w.tok_cd,w.kbn,uri_row_kai