-- ์ง์ ์ง ์ฝ๋.
SELECT C.FLAVOR FROM
(
SELECT A.SHIPMENT_ID, A.FLAVOR, SUM(A.TOTAL_ORDER + B.TOTAL_ORDER) AS TOTAL
FROM FIRST_HALF A
JOIN JULY B ON A.FLAVOR = B.FLAVOR
GROUP BY FLAVOR
ORDER BY TOTAL DESC
) AS C
ORDER BY C.TOTAL DESC
LIMIT 3
-- GPT๋ก๋ถํฐ ์ฒจ์ญ๋ฐ์.
SELECT C.FLAVOR FROM
(
SELECT A.FLAVOR, SUM(A.TOTAL_ORDER + B.TOTAL_ORDER) AS TOTAL
FROM FIRST_HALF A
JOIN JULY B ON A.FLAVOR = B.FLAVOR
GROUP BY FLAVOR
) AS C
ORDER BY C.TOTAL DESC
LIMIT 3
-- ์ธํฐ๋ท์์ ์ฐพ์ ๋ฐฉ๋ฒ.
SELECT A.FLAVOR
FROM FIRST_HALF A
JOIN
(
SELECT FLAVOR, SUM(TOTAL_ORDER) AS TOTAL_ORDER
FROM JULY
GROUP BY FLAVOR
) AS B
ON A.FLAVOR = B.FLAVOR
ORDER BY A.TOTAL_ORDER + B.TOTAL_ORDER DESC
LIMIT 3
728x90
':: DBMS ๐ฉ > ํ๋ก๊ทธ๋๋จธ์ค SQL ๊ณ ๋์ kit ํ์ด' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
JOIN>๋ณดํธ์์์ ์ค์ฑํํ ๋๋ฌผ (0) | 2023.02.26 |
---|---|
JOIN>5์ ์ํ๋ค์ ์ด๋งค์ถ ์กฐํํ๊ธฐ (0) | 2023.02.26 |
JOIN>๊ทธ๋ฃน๋ณ ์กฐ๊ฑด์ ๋ง๋ ์๋น ๋ชฉ๋ก ์ถ๋ ฅํ๊ธฐ (0) | 2023.02.26 |
JOIN>์ค๋ ๊ธฐ๊ฐ ๋ณดํธํ ๋๋ฌผ(1) (0) | 2023.02.26 |
JOIN>์์๋๋ฐ์ ์์์ต๋๋ค (0) | 2023.02.26 |
๋๊ธ