[selectRecords] select kbn ,cd ,han ,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 1 as kbn ,coalesce(m.cat_cd,'') as cd ,coalesce(hn.han_name,'')||'('||coalesce(m.cat_cd,'')||')' as han ,sum(coalesce(um.kingaku,0)) as kingaku ,sum(coalesce(um.genka_gaku,0)) as genka ,sum(coalesce(um.kingaku,0))-sum(coalesce(um.genka_gaku,0)) as arari ,case (sum(coalesce(um.kingaku,0))) when 0 then 0 else round((sum(coalesce(um.kingaku,0))-sum(coalesce(um.genka_gaku,0)))*100/(sum(coalesce(um.kingaku,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) where 1=1 and t.jucyu_flg = '0' and t.del_flg = '0' --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')) group by coalesce(m.cat_cd,''),coalesce(hn.han_name,'')||'('||coalesce(m.cat_cd,'')||')' union all select 2 as kbn ,null as cd ,'全体合計' as han ,sum(coalesce(um.kingaku,0)) as kingaku ,sum(coalesce(um.genka_gaku,0)) as genka ,sum(coalesce(um.kingaku,0))-sum(coalesce(um.genka_gaku,0)) as arari ,case (sum(coalesce(um.kingaku,0))) when 0 then 0 else round((sum(coalesce(um.kingaku,0))-sum(coalesce(um.genka_gaku,0)))*100/(sum(coalesce(um.kingaku,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) where 1=1 and t.jucyu_flg = '0' and t.del_flg = '0' --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')) ) s1 order by s1.cd,s1.kbn; [selectGraph] select coalesce(m.cat_cd,'') as tok_cd ,coalesce(hn.han_name,'')||'('||coalesce(m.cat_cd,'')||')' as tok_nm ,sum(coalesce(um.kingaku,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) where 1 = 1 and t.jucyu_flg = 0 and t.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')) group by coalesce(m.cat_cd,''),coalesce(hn.han_name,'')||'('||coalesce(m.cat_cd,'')||')' order by kingaku DESC limit 5