[selectRecords] select 'お客様コード:'||tok_cd as tokui_cd_s, (case tokui_nm when '' then '' else tokui_nm ||' '|| (case keisyo when '' then '様' else keisyo end) end) as tokui_nm_s, left(zip_no,3)||'-'||right(zip_no,4) as post_n, (case when(nyukin_ymd != '')then(to_char(to_date(nyukin_ymd, 'YYYYMMDD'), 'yyyy/mm/dd'))else('')end) as nyukin_ymd, (case when(seikyu_ymd != '')then(to_char(to_date(seikyu_ymd, 'YYYYMMDD'), 'yyyy/mm/dd'))else('')end) as seikyu_ymd, (case when(tegata_ymd != '')then(to_char(to_date(tegata_ymd, 'YYYYMMDD'), 'yyyy/mm/dd'))else('')end) as tegata_ymd, '担当:'||tan_nm as tan_nm_s, v.* from( select --tn tn.nyukin_no, tn.tok_cd, tn.nyukin_ymd, tn.nyukin_kbn, tn.nyukin_gaku, tn.total_gaku, tn.biko, tn.seikyu_flg, tn.seikyu_ymd, tn.tan_cd, tn.tegata_ymd, tn.tegata_no, --mt coalesce(mt.keisyo,'') as keisyo, coalesce(mt.tok_nm,'') as tokui_nm, mt.tok_kana as tokui_kana, mt.zip_no, mt.addr1, mt.addr2, mt.addr3, --tan tan.tan_nm, --han han1.han_name as nyukin_nm, --w w.total_gaku_sum from t_nyukin tn left join m_tokui mt on (tn.tok_cd = mt.tok_cd) left join m_tanto tan on (tn.tan_cd = tan.tan_cd) left join m_hanyo han1 on (tn.nyukin_kbn = han1.han_cd and han1.mst_kbn = '13') left join ( select tok_cd, nyukin_ymd, trunc(sum(total_gaku)) as total_gaku_sum from t_nyukin tn where 1=1 and (tn.nyukin_no = fnc_to_number('&8') or '' = '&8') and (tn.tok_cd >= '&3' or '' = '&3') and (tn.tok_cd <= '&4' or '' = '&4') and (tn.tan_cd >= '&5' or '' = '&5') and (tn.tan_cd <= '&6' or '' = '&6') and (tn.nyukin_ymd >= '&1' or '' = '&1') and (tn.nyukin_ymd <= '&2' or '' = '&2') group by nyukin_ymd,tok_cd ) w on (tn.tok_cd = w.tok_cd and tn.nyukin_ymd = w.nyukin_ymd)--入金ヘッダ合計 where 1=1 and (tn.nyukin_no = fnc_to_number('&8') or '' = '&8') and (tn.tok_cd >= '&3' or '' = '&3') and (tn.tok_cd <= '&4' or '' = '&4') and (tn.tan_cd >= '&5' or '' = '&5') and (tn.tan_cd <= '&6' or '' = '&6') and (tn.nyukin_ymd >= '&1' or '' = '&1') and (tn.nyukin_ymd <= '&2' or '' = '&2') )v order by v.nyukin_no,v.nyukin_ymd,v.tok_cd [SelectRecords_Jisya] select 'TEL:' || j_tel as j_tel_s ,'FAX:' || j_fax as j_fax_s ,(case j_url when '' then '' else 'URL:' || j_url end) as j_url_s --,'URL:' || j_url as j_url_s ,(case j_daihyo when '' then '' else '担当者:' || j_daihyo end) as j_daihyo_s ,w.* from( select '発注書' as tait ,j.mst_kbn ,j.han_cd ,j.han_name as j_nm ,j.koumoku1 as j_post_s ,j.koumoku2 as j_address ,j.koumoku3 as j_address2 ,j.koumoku4 as j_address3 ,j.koumoku5 as j_tel ,j.koumoku6 as j_fax ,j.koumoku7 as j_url ,j.koumoku8 as j_daihyo -- ,j.koumoku9 -- ,j.koumoku10 ,j.sort_key ,j2.mst_kbn ,j2.han_cd ,j2.han_name ,j2.koumoku1 as koumoku1 ,j2.koumoku2 as koumoku2 ,j2.koumoku3 as koumoku3 ,j2.koumoku4 as koumoku4 ,j2.koumoku5 as koumoku5 ,j2.koumoku6 as koumoku6 ,j2.koumoku7 as koumoku7 ,j2.koumoku8 as koumoku8 ,j2.koumoku9 as koumoku9 ,j2.koumoku10 as koumoku10 , '(注)社印がない場合は、無効です。' as mongon1 , '但し、' as mongon2 , '' as mongon3 , '' as mongon4 , '' as mongon5 from m_hanyo j left join m_hanyo j2 on (j2.mst_kbn = '90' and j2.han_cd = 'jisya2') where 1=1 and j.mst_kbn = '90' and j.han_cd = 'jisya' )w