[selectRecords] select uh.den_no , to_char(to_date(uh.syori_ymd,'YYYYMMDD'),'YYYY/MM/DD') as syori_ymd , (case when(uh.nonyu_ymd != '')then(to_char(to_date(uh.nonyu_ymd,'YYYYMMDD'),'YYYY/MM/DD'))else('')end) as nonyu_ymd , uh.den_kbn , h54.han_name as den_kbn_nm , uh.via_flg , (case when(uh.via_flg = 1)then('商社')else('')end) as via_flg_nm , uh.tok_cd , uh.tok_nm , uh.kanri_no , uh.tok_hacyu_no , uh.tan_cd , tan.tan_nm , uh.zeinuki_gaku as kingaku_kei --#20008 2021.07.21 MOD STT --, (select sum(um2.suryo) from t_uri_m um2 where um2.den_no = uh.den_no) as suryo_kei , (select sum(um2.suryo) from t_uri_m um2 where um2.den_no = uh.den_no and um2.set_row_no is null) as suryo_kei --#20008 2021.07.21 MOD END , um.row_no , um.rel_row_no , (case when(um.hosoku2 != '')then(um.hin_nm)else(um.hin_cd)end) as hin_cd , (case when(um.hosoku2 != '')then(um.hin_nm_ext)else(um.hin_nm)end) as hin_nm --#20008 2021.07.21 MOD STT --, um.price_rank --, um.suryo --, um.kingaku , (case when(um.set_row_no is not null)then(null)else(um.price_rank)end) as price_rank , (case when(um.set_row_no is not null)then(null)else(um.suryo)end) as suryo , (case when(um.set_row_no is not null)then(null)else(um.kingaku)end) as kingaku --#20008 2021.07.21 MOD END , um.gentanka , um.tanka , um.hosoku2 , uh.eig_cd , h79.han_name as eig_nm , cast(jm.den_no as varchar)||'-'||to_char(jm.rel_row_no,'FM00') as jucyu_no_str , replace(replace(uh.biko1,chr(10),''),chr(13),'') as biko1 , replace(replace(uh.biko2,chr(10),''),chr(13),'') as biko2 from t_uri uh inner join t_uri_m um on (um.den_no = uh.den_no) left join t_uri_m jm on (jm.den_no = um.jucyu_no and jm.row_no = um.jucyu_row_no) left join m_tanto tan on (tan.tan_cd = uh.tan_cd) left join m_hanyo h54 on (h54.mst_kbn = '54' and h54.han_cd = uh.den_kbn) left join m_hanyo h79 on (h79.mst_kbn = '79' and h79.han_cd = uh.eig_cd) where 1 = 1 and uh.del_flg = 0 and uh.jucyu_flg = 0 and COALESCE(uh.mitsumori_flg,0) = 0 --商社発生伝票は対象外 and COALESCE(uh.via_seq,0) = 0 and ((uh.syori_ymd >= '&1') or ('&1' = '')) and ((uh.syori_ymd <= '&2') or ('&2' = '')) and ((uh.input_ymd >= '&7') or ('&7' = '')) and ((uh.input_ymd <= '&8') or ('&8' = '')) and ((uh.den_no = cast('0'||'&3' as int)) or ('' = '&3')) and ((uh.tok_cd = '&4') or ('&4' = '')) and ((uh.eig_cd = '&6') or ('&6' = '')) order by uh.eig_cd, um.den_no, um.row_no