SELECT
TO_CHAR(T007.NENGETSU)
,TO_CHAR(T001.DEN_DATE)
,TO_CHAR(T001.DEN_NO)
,TO_CHAR(T001.DEN_GYO_NO)
,T001.DEN_SYO_CD
,T002.SYO_KANA
,TO_CHAR(T001.TOTAL_QTY)
,TO_CHAR(T001.URI_TAN)
,TO_CHAR(T001.URI_KIN_ZEINUKI)
,TO_CHAR(decode( T001.CASE_QTY,0,0,mod( T001.BARA_QTY, T001.CASE_QTY)))
FROM
DC2_DEMO.SAM_DENPYO T001
LEFT OUTER JOIN DC2_DEMO.SAM_DAY T007 ON
 T001.DEN_DATE=T007.HIDUKE
LEFT OUTER JOIN DC2_DEMO.SAM_SYOHIN T002 ON
 T001.DEN_SYO_CD=T002.SYO_CD
WHERE
 T001.DEN_KB='2'
 AND T001.DEN_DATE BETWEEN '20100101' AND '20100110'
ORDER BY
  T001.DEN_DATE
 ,T001.DEN_NO
 ,T001.DEN_GYO_NO
