[selectRecords] select eig_cd ,eig_nm ,tok_cd ,tok_nm ,kingaku ,genka ,arari ,ritu ,case ('&16') when '' then '未指定' else to_char(to_date('&16', 'YYYYMMDD'), 'yyyy/mm/dd') end as dt_fr ,case ('&17') when '' then '未指定' else to_char(to_date('&17', 'YYYYMMDD'), 'yyyy/mm/dd') end as dt_to from ( select coalesce(t.eig_cd,'') as eig_cd ,coalesce(h79.han_name,'') as eig_nm ,coalesce(t.tok_cd,'') as tok_cd ,coalesce(m.tok_nm,'')||'('||coalesce(t.tok_cd,'')||')' as tok_nm ,sum(coalesce(t.zeinuki_gaku,0)) as kingaku ,sum(coalesce(t.genka_gaku,0)) as genka ,sum(coalesce(t.zeinuki_gaku,0))-sum(coalesce(t.genka_gaku,0)) as arari ,case (sum(coalesce(t.zeinuki_gaku,0))) when 0 then 0 else round((sum(coalesce(t.zeinuki_gaku,0))-sum(coalesce(t.genka_gaku,0)))*100/(sum(coalesce(t.zeinuki_gaku,0))),1) end as ritu ,case ('&16') when '' then '未指定' else to_char(to_date('&16', 'YYYYMMDD'), 'yyyy/mm/dd') end as dt_fr ,case ('&17') when '' then '未指定' else to_char(to_date('&17', 'YYYYMMDD'), 'yyyy/mm/dd') end as dt_to from t_tok_eig_getsu t --left join t_uri t on (t.tok_cd = main.tok_cd and t.syori_ymd >= main.stt_ymd and t.syori_ymd <= main.end_ymd) --left join t_uri_m um on (t.den_no = um.den_no) left join m_tokui m on (m.tok_cd = t.tok_cd) --left join m_hin hi on (hi.hin_cd = um.hin_cd) left join m_hanyo hn on (hn.mst_kbn = '35' and hn.han_cd = m.cat_cd) --left join m_tanto tn on (tn.tan_cd = t.tan_cd) --left join m_hanyo hn1 on (hn1.mst_kbn = '55' and hn1.han_cd = tn.bu_cd) --left join m_hanyo h01 on (h01.mst_kbn = '01' and h01.han_cd = t.prc_sts) left join m_hanyo h79 on (h79.mst_kbn = '79' and h79.han_cd = t.eig_cd) where 1 = 1 --and t.jucyu_flg = 0 and t.del_flg = 0 --and coalesce(h01.koumoku3, '') = '' and t.syori_ym = '&5&6' --and hi.del_flg = '0' --and (('' = '&16') or (t.syori_ymd >= '&16')) --and (('' = '&17') or (t.syori_ymd <= '&17')) --and (('' = '&2') or (tn.bu_cd = '&2')) --and (('' = '&24') or (t.tan_cd >= '&24')) --and (('' = '&25') or (t.tan_cd <= '&25')) --and (('' = '&4') or (m.cat_cd = '&4')) --and (('' = '&20') or (m.tok_cd >= '&20')) --and (('' = '&21') or (m.tok_cd <= '&21')) and (('' = '&8') or (m.tok_cd >= '&8')) and (('' = '&9') or (m.tok_cd <= '&9')) and (t.eig_cd >= '&25' or '' = '&25') and (t.eig_cd <= '&26' or '' = '&26') --group by coalesce(m.cat_cd,''),hn.han_name,t.tok_cd,t.eig_cd,m.tok_nm,coalesce(h79.han_name,'') group by coalesce(m.cat_cd,''),hn.han_name,t.tok_cd,t.eig_cd,h79.han_name,m.tok_nm ) s1 order by eig_cd,s1.tok_cd,s1.tok_nm; [selectRecords_@@] select eig_cd ,eig_nm ,tok_cd ,tok_nm ,kingaku ,genka ,arari ,ritu ,case ('&16') when '' then '未指定' else to_char(to_date('&16', 'YYYYMMDD'), 'yyyy/mm/dd') end as dt_fr ,case ('&17') when '' then '未指定' else to_char(to_date('&17', 'YYYYMMDD'), 'yyyy/mm/dd') end as dt_to from ( select coalesce(t.eig_cd,'') as eig_cd ,coalesce(h79.han_name,'') as eig_nm ,coalesce(t.tok_cd,'') as tok_cd ,coalesce(t.tok_nm,'')||'('||coalesce(t.tok_cd,'')||')' as tok_nm ,sum(coalesce(um.zeinuki_gaku,0)) as kingaku ,sum(coalesce(um.genka_gaku,0)) as genka ,sum(coalesce(um.zeinuki_gaku,0))-sum(coalesce(um.genka_gaku,0)) as arari ,case (sum(coalesce(um.zeinuki_gaku,0))) when 0 then 0 else round((sum(coalesce(um.zeinuki_gaku,0))-sum(coalesce(um.genka_gaku,0)))*100/(sum(coalesce(um.zeinuki_gaku,0))),1) end as ritu ,case ('&16') when '' then '未指定' else to_char(to_date('&16', 'YYYYMMDD'), 'yyyy/mm/dd') end as dt_fr ,case ('&17') when '' then '未指定' else to_char(to_date('&17', 'YYYYMMDD'), 'yyyy/mm/dd') end as dt_to from t_uri_m um left join t_uri t on (t.den_no = um.den_no) left join m_tokui m on (m.tok_cd = t.tok_cd) left join m_hin hi on (hi.hin_cd = um.hin_cd) left join m_hanyo hn on (hn.mst_kbn = '35' and hn.han_cd = m.cat_cd) left join m_tanto tn on (tn.tan_cd = t.tan_cd) left join m_hanyo hn1 on (hn1.mst_kbn = '55' and hn1.han_cd = tn.bu_cd) left join m_hanyo h01 on (h01.mst_kbn = '01' and h01.han_cd = t.prc_sts) left join m_hanyo h79 on (h79.mst_kbn = '79' and h79.han_cd = t.eig_cd) where 1 = 1 and t.jucyu_flg = 0 and t.del_flg = 0 and coalesce(h01.koumoku3, '') = '' --and hi.del_flg = '0' --and (('' = '&16') or (t.syori_ymd >= '&16')) --and (('' = '&17') or (t.syori_ymd <= '&17')) --and (('' = '&2') or (tn.bu_cd = '&2')) --and (('' = '&24') or (t.tan_cd >= '&24')) --and (('' = '&25') or (t.tan_cd <= '&25')) --and (('' = '&4') or (m.cat_cd = '&4')) --and (('' = '&20') or (m.tok_cd >= '&20')) --and (('' = '&21') or (m.tok_cd <= '&21')) and (('' = '&8') or (m.tok_cd >= '&8')) and (('' = '&9') or (m.tok_cd <= '&9')) and (t.eig_cd >= '&25' or '' = '&25') and (t.eig_cd <= '&26' or '' = '&26') group by coalesce(m.cat_cd,''),hn.han_name,t.tok_cd,t.eig_cd,t.tok_nm,coalesce(h79.han_name,'') ) s1 order by eig_cd,s1.tok_cd,s1.tok_nm; [selectGraph] select t.tok_cd ,coalesce(t.tok_nm,'')||'('||coalesce(t.tok_cd,'')||')' as tok_nm ,sum(coalesce(um.zeinuki_gaku,0))-sum((case when(&31 = 1)then(coalesce(um.genka_gaku,0))else(0)end)) as kingaku from t_uri_m um left join t_uri t on (t.den_no = um.den_no) left join m_tokui m on (m.tok_cd = t.tok_cd) left join m_hin hi on (hi.hin_cd = um.hin_cd) left join m_hanyo hn on (hn.mst_kbn = '35' and hn.han_cd = m.cat_cd) left join m_tanto tn on (tn.tan_cd = t.tan_cd) left join m_hanyo hn1 on (hn1.mst_kbn = '55' and hn1.han_cd = tn.bu_cd) left join m_hanyo h01 on (h01.mst_kbn = '01' and h01.han_cd = t.prc_sts) where 1 = 1 and t.jucyu_flg = 0 and t.del_flg = 0 and coalesce(h01.koumoku3, '') = '' and (('' = '&8') or (m.tok_cd >= '&8')) and (('' = '&9') or (m.tok_cd <= '&9')) and (t.eig_cd >= '&25' or '' = '&25') and (t.eig_cd <= '&26' or '' = '&26') /* and (('' = '&16') or (t.syori_ymd >= '&16')) and (('' = '&17') or (t.syori_ymd <= '&17')) and (('' = '&2') or (tn.bu_cd = '&2')) and (('' = '&24') or (t.tan_cd >= '&24')) and (('' = '&25') or (t.tan_cd <= '&25')) and (('' = '&4') or (m.cat_cd = '&4')) and (('' = '&20') or (m.tok_cd >= '&20')) and (('' = '&21') or (m.tok_cd <= '&21')) */ group by t.tok_cd ,coalesce(t.tok_nm,'')||'('||coalesce(t.tok_cd,'')||')' order by kingaku DESC limit 5