728x90
320x100
MySQL
SELECT FLAVOR
FROM (SELECT FLAVOR
, SUM(TOTAL_ORDER) AS TOTAL_ORDER
FROM ( SELECT * FROM FIRST_HALF UNION ALL SELECT * FROM JULY) A
GROUP BY FLAVOR
ORDER BY TOTAL_ORDER DESC
LIMIT 3) B
Oracle
SELECT FLAVOR
FROM (SELECT A.FLAVOR
, A.TOTAL_ORDER + B.TOTAL_ORDER AS TOTAL_ORDER
FROM (SELECT FLAVOR
, SUM(TOTAL_ORDER) AS TOTAL_ORDER
FROM FIRST_HALF
GROUP BY FLAVOR) A,
(SELECT FLAVOR
, SUM(TOTAL_ORDER) AS TOTAL_ORDER
FROM JULY
GROUP BY FLAVOR) B
WHERE A.FLAVOR = B.FLAVOR
ORDER BY TOTAL_ORDER DESC
)
WHERE ROWNUM < 4
;
728x90
320x100
'💻 하나씩 차곡차곡 > 프로그래머스 (SQL)' 카테고리의 다른 글
[JOIN/LEVEL4] 특정 기간동안 대여 가능한 자동차들의 대여비용 구하기 (MySQL/Oracle) (0) | 2024.11.20 |
---|---|
[JOIN/LEVEL4] FrontEnd 개발자 찾기 (MySQL) (0) | 2024.11.19 |
[JOIN/LEVEL4] 5월 식품들의 총매출 조회하기 (MySQL/Oracle) (0) | 2024.11.15 |
[JOIN/LEVEL3] 있었는데요 없었습니다 (MySQL/Oracle) (1) | 2024.11.13 |
[JOIN/LEVEL2] 상품 별 오프라인 매출 구하기 (MySQL/Oracle) (0) | 2024.11.12 |