We have created a awesome theme
Far far away,behind the word mountains, far from the countries

INFO ½ÇÀü DB¸ðµ¨¸µ°ú SQL°úÁ¤

INFO

½ÇÀü DB¸ðµ¨¸µ°ú SQL°úÁ¤
Á¶È¸¼ö 943
Á¦¸ñ Chapter14_¾Ë¾ÆµÎ¾î¾ß ÇÒ ±âŸ¼³°è : ¿¹Á¦¸ðÀ½
ÀÛ¼ºÀÚ °ü¸®ÀÚ
ÀÛ¼ºÀÏÀÚ 2021-12-03

¡á¿¹ 14_1  ||  ÀÏÀÚº° ÀüÇ¥³â¿ùÀÏÁý°è Å×À̺í INSERT
DELETE * FROM ³â¿ùÀÏÁý°è
WHERE ¹ßÇà³â¿ùÀÏ = :IN_TODAY;

INSERT INTO ³â¿ùÀÏÁý°è
    (°Å·¡Ã³ÄÚµå, ¹ßÇà³â¿ùÀÏ,ÀÔÃⱸºÐ,±Ý¾×)              
____SELECT °Å·¡Ã³ÄÚµå, :in_today , ÀÔÃⱸºÐ, SUM(±Ý¾×)
FROM ÀüÇ¥
WHERE ¹ßÇàÀϽà >= TO_DATE(:in_today, 'YYYYMMDD')
AND   ¹ßÇàÀϽà <  TO_DATE(:in_today, 'YYYYMMDD')+1
GROUP BY  °Å·¡Ã³ÄÚµå, ÀÔÃⱸºÐ;



¡á¿¹ 14_1_2  ||  ÀÏÀÚº° ÀüÇ¥³â¿ùÀÏÁý°è Å×À̺í INSERT
SELECT °Å·¡Ã³ÄÚµå, ÀÔÃⱸºÐ, SUM(±Ý¾×)
FROM
        (--Áý°èÅ×ÀÌºí¿¡¼­ ÀüÀÏÀÚ ±îÁö °¡Á®¿Â´Ù.
        SELECT °Å·¡Ã³ÄÚµå, ÀÔÃⱸºÐ, ±Ý¾×
        FROM ³â¿ùÀÏÁý°è
        WHERE ¹ßÇà³â¿ùÀÏ >= :IN_FROM_DATE
        AND   ¹ßÇà³â¿ùÀÏ < TO_CHAR(SYSDATE,'YYYYMMDD')
UNION ALL
        --¿À´Ã ÀüÇ¥¹ß»ý µ¥ÀÌÅ͸¦ °¡Á®¿Â´Ù.
        SELECT °Å·¡Ã³ÄÚµå, ÀÔÃⱸºÐ, ±Ý¾×
        FROM____ ÀüÇ¥
        WHERE ¹ßÇàÀϽà >= TO_DATE(TO_CHAR(SYSDATE,'yyyymmdd'))
        AND   ¹ßÇàÀϽà <=  SYSDATE )
GROUP BY °Å·¡Ã³ÄÚµå, ÀÔÃⱸºÐ;

÷ºÎÆÄÀÏ