-- 물품입출고 내역을 이용한 재고수량
SELECT P.*, PC.* FROM PRODUCT P, (
SELECT PRODUCT_NO, SUM(CNT) CNT FROM PRODUCTCOUNT GROUP BY PRODUCT_NO) PC
WHERE P.NO = PC.PRODUCT_NO;
SELECT P.*, PC.* FROM PRODUCT P INNER JOIN (
SELECT PRODUCT_NO, SUM(CNT) CNT FROM PRODUCTCOUNT GROUP BY PRODUCT_NO) PC
ON P.NO = PC.PRODUCT_NO;
CREATE OR REPLACE VIEW PRODUCT_VIEW AS
SELECT P.*, PC.* FROM PRODUCT P LEFT OUTER JOIN (
SELECT PRODUCT_NO, SUM(CNT) CNT FROM PRODUCTCOUNT GROUP BY PRODUCT_NO) PC
ON P.NO = PC.PRODUCT_NO;