코딩테스트 연습 > String, Date > 조건에 부합하는 중고거래 상태 조회하기
https://school.programmers.co.kr/learn/courses/30/lessons/164672

거래 상태에 따라 다른 출력을 위해 case를 사용한다.
SELECT board_id, writer_id, title, price,
case when status = 'SALE' then '판매중'
when status = 'RESERVED' then '예약중'
else '거래완료'
END as 거래상태
from used_goods_board u
where year(created_date) = 2022 and month(created_date) = 10 and day(created_date) = 5
order by board_id desc
날짜를 확인 할 때, 년도는 year, 월은 month, 일은 day로 확인할 수 있고,
case문은 조건 when 상태 status, 상태에 따른 결과 then을 이용할 수 있다. 또한, case문을 끝내는 방식으로 END를 사용한다.