DELETE FROM DC2.OR_100 WHERE PV_USER = '361';
commit;
INSERT INTO DC2.OR_100 (PV_KEY,PV_USER,PV1)
SELECT LPAD(TO_CHAR(ROWNUM),20,0),TABLE_SELECT.* FROM (
SELECT '361',COUNT(*)
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_TORIHIKI T006 ON
 T001.SOUKO=T006.TOR_CD
 AND T006.TOR_KB='0'
WHERE
 T001.DEN_KB='2'
 AND T007.NENGETSU BETWEEN '20090101' AND '20091201'
) TABLE_SELECT
;
commit;
EXIT;


