1.
code:
SELECT II.INGREDIENT_TYPE, SUM(FH.TOTAL_ORDER)
FROM FIRST_HALF FH
JOIN ICECREAM_INFO II ON FH.FLAVOR = II.FLAVOR
GROUP BY INGREDIENT_TYPE
ORDER BY INGREDIENT_TYPE DESC
2.
code:
SELECT ORDER_ID, PRODUCT_ID, OUT_DATE
from FOOD_ORDER
where OUT_DATE like "%2022-05-01%"
Answer:
SELECT ORDER_ID, PRODUCT_ID, DATE_FORMAT(OUT_DATE, '%Y-%m-%d') AS OUT_DATE,
CASE
WHEN OUT_DATE IS NULL THEN '출고미정'
WHEN OUT_DATE <= '2022-05-01' THEN '출고완료'
WHEN OUT_DATE > '2022-05-01' THEN '출고대기'
END AS 출고여부
FROM FOOD_ORDER
ORDER BY ORDER_ID ASC;
-Case: 조건에 따라 값 정하기
참고 사이트: https://suy379.tistory.com/110#google_vignette
'SQL 문제들' 카테고리의 다른 글
SQL 문제들(join) (1) | 2024.11.20 |
---|---|
SQL 문제들(join 문제들) (0) | 2024.11.19 |
sql 문제1 (0) | 2024.11.16 |
SQL 세션 문제2(해결중) (1) | 2024.10.17 |