[selectRecords] select kbn ,c2kbn ,c1kbn ,cd2 ,han2 ,cd1 ,han1 ,hin_cd ,hin_nm ,suryo ,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 ,1 as c2kbn ,1 as c1kbn ,coalesce(hn2.han_cd,'') as cd2 ,'('||coalesce(hn2.han_cd,'')||')'||coalesce(hn2.han_name,'') as han2 ,coalesce(hn1.han_cd,'') as cd1 ,'('||coalesce(hn1.han_cd,'')||')'||coalesce(hn1.han_name,'') as han1 ,um.hin_cd ,um.hin_nm ,sum(coalesce(um.suryo,0)) as suryo ,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 t left join t_uri_m um on (um.den_no = t.den_no) left join m_hin hi on (hi.hin_cd = um.hin_cd ) left join m_hanyo hn1 on (hn1.mst_kbn = '05' and hn1.han_cd = hi.cat_cd) left join m_hanyo hn2 on (hn2.mst_kbn = '14' and hn2.han_cd = hn1.koumoku1) 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 hi.del_flg = 0 and coalesce(h01.koumoku3, '') = '' and (('' = '&16') or (t.syori_ymd >= '&16')) and (('' = '&17') or (t.syori_ymd <= '&17')) AND (('' = '&8') or (hn1.han_cd is not null and hn1.koumoku1 >= '&8')) AND (('' = '&9') or (hn1.han_cd is not null and hn1.koumoku1 <= '&9')) AND (('' = '&12') or (hi.cat_cd >= '&12')) AND (('' = '&13') or (hi.cat_cd <= '&13')) AND (('' = '&28') or (hi.hin_cd >= '&28')) AND (('' = '&29') or (hi.hin_cd <= '&29')) group by coalesce(hn2.han_cd,''),hn2.han_name,coalesce(hn1.han_cd,''),hn1.han_name,um.hin_cd,um.hin_nm union all select 1 as kbn ,1 as c2kbn ,2 as c1kbn ,coalesce(hn2.han_cd,'') as cd2 ,'('||coalesce(hn2.han_cd,'')||')'||coalesce(hn2.han_name,'') as han2 ,coalesce(hn1.han_cd,'') as cd1 ,'('||coalesce(hn1.han_cd,'')||')'||coalesce(hn1.han_name,'') as han1 ,'' as hin_cd ,'商品分類合計' as hin_nm ,sum(coalesce(um.suryo,0)) as suryo ,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 t left join t_uri_m um on (um.den_no = t.den_no) left join m_hin hi on (hi.hin_cd = um.hin_cd ) left join m_hanyo hn1 on (hn1.mst_kbn = '05' and hn1.han_cd = hi.cat_cd) left join m_hanyo hn2 on (hn2.mst_kbn = '14' and hn2.han_cd = hn1.koumoku1) 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 hi.del_flg = 0 and coalesce(h01.koumoku3, '') = '' and (('' = '&16') or (t.syori_ymd >= '&16')) and (('' = '&17') or (t.syori_ymd <= '&17')) AND (('' = '&8') or (hn1.han_cd is not null and hn1.koumoku1 >= '&8')) AND (('' = '&9') or (hn1.han_cd is not null and hn1.koumoku1 <= '&9')) AND (('' = '&12') or (hi.cat_cd >= '&12')) AND (('' = '&13') or (hi.cat_cd <= '&13')) AND (('' = '&28') or (hi.hin_cd >= '&28')) AND (('' = '&29') or (hi.hin_cd <= '&29')) group by coalesce(hn2.han_cd,''),hn2.han_name,coalesce(hn1.han_cd,''),hn1.han_name union all select 1 as kbn ,2 as c2kbn ,1 as c1kbn ,coalesce(hn2.han_cd,'') as cd2 ,'('||coalesce(hn2.han_cd,'')||')'||coalesce(hn2.han_name,'') as han2 ,'' as cd1 ,'' as han1 ,'' as hin_cd ,'商品大分類合計' as hin_nm ,sum(coalesce(um.suryo,0)) as suryo ,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 t left join t_uri_m um on (um.den_no = t.den_no) left join m_hin hi on (hi.hin_cd = um.hin_cd ) left join m_hanyo hn1 on (hn1.mst_kbn = '05' and hn1.han_cd = hi.cat_cd) left join m_hanyo hn2 on (hn2.mst_kbn = '14' and hn2.han_cd = hn1.koumoku1) 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 hi.del_flg = 0 and coalesce(h01.koumoku3, '') = '' and (('' = '&16') or (t.syori_ymd >= '&16')) and (('' = '&17') or (t.syori_ymd <= '&17')) AND (('' = '&8') or (hn1.han_cd is not null and hn1.koumoku1 >= '&8')) AND (('' = '&9') or (hn1.han_cd is not null and hn1.koumoku1 <= '&9')) AND (('' = '&12') or (hi.cat_cd >= '&12')) AND (('' = '&13') or (hi.cat_cd <= '&13')) AND (('' = '&28') or (hi.hin_cd >= '&28')) AND (('' = '&29') or (hi.hin_cd <= '&29')) group by coalesce(hn2.han_cd,''),hn2.han_name union all select 2 as kbn ,null as c2kbn ,null as c1kbn ,'' as cd2 ,'' as han2 ,'' as cd1 ,'' as han1 ,'' as hin_cd ,'合計' as hin_nm ,sum(coalesce(um.suryo,0)) as suryo ,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 t left join t_uri_m um on (um.den_no = t.den_no) left join m_hin hi on (hi.hin_cd = um.hin_cd ) left join m_hanyo hn1 on (hn1.mst_kbn = '05' and hn1.han_cd = hi.cat_cd) left join m_hanyo hn2 on (hn2.mst_kbn = '14' and hn2.han_cd = hn1.koumoku1) 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 hi.del_flg = 0 and coalesce(h01.koumoku3, '') = '' and (('' = '&16') or (t.syori_ymd >= '&16')) and (('' = '&17') or (t.syori_ymd <= '&17')) AND (('' = '&8') or (hn1.han_cd is not null and hn1.koumoku1 >= '&8')) AND (('' = '&9') or (hn1.han_cd is not null and hn1.koumoku1 <= '&9')) AND (('' = '&12') or (hi.cat_cd >= '&12')) AND (('' = '&13') or (hi.cat_cd <= '&13')) AND (('' = '&28') or (hi.hin_cd >= '&28')) AND (('' = '&29') or (hi.hin_cd <= '&29')) ) s1 order by s1.kbn,s1.cd2,s1.han2,s1.c2kbn,s1.cd1,s1.han1,s1.c1kbn,s1.hin_cd,s1.hin_nm [selectGraph] select um.hin_cd ,um.hin_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 t left join t_uri_m um on (um.den_no = t.den_no) left join m_hin hi on (hi.hin_cd = um.hin_cd and hi.del_flg = 0) left join m_hanyo hn1 on (hn1.mst_kbn = '05' and hn1.han_cd = hi.cat_cd) left join m_hanyo hn2 on (hn2.mst_kbn = '14' and hn2.han_cd = hn1.koumoku1) 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 (('' = '&16') or (t.syori_ymd >= '&16')) and (('' = '&17') or (t.syori_ymd <= '&17')) AND (('' = '&8') or (hn1.han_cd is not null and hn1.koumoku1 >= '&8')) AND (('' = '&9') or (hn1.han_cd is not null and hn1.koumoku1 <= '&9')) AND (('' = '&12') or (hi.cat_cd >= '&12')) AND (('' = '&13') or (hi.cat_cd <= '&13')) AND (('' = '&28') or (hi.hin_cd >= '&28')) AND (('' = '&29') or (hi.hin_cd <= '&29')) group by um.hin_cd, um.hin_nm order by kingaku DESC limit 5