๐Ÿ’ SQL (Programmers)/String, Date

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL ๊ณ ๋“์  Kit : ์กฐ๊ฑด์— ๋ถ€ํ•ฉํ•˜๋Š” ์ค‘๊ณ ๊ฑฐ๋ž˜ ์ƒํƒœ ์กฐํšŒํ•˜๊ธฐ

์„ ๋‹ฌ 2023. 5. 8. 23:18
๋ฐ˜์‘ํ˜•

https://school.programmers.co.kr/learn/courses/30/lessons/164672

 

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.

programmers.co.kr

 

 

-- ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”
SELECT BOARD_ID, WRITER_ID, TITLE, PRICE, case 
    when STATUS = 'SALE' then 'ํŒ๋งค์ค‘'
    when STATUS = 'RESERVED' then '์˜ˆ์•ฝ์ค‘'
    when STATUS = 'DONE' then '๊ฑฐ๋ž˜์™„๋ฃŒ'
    end STATUS
from USED_GOODS_BOARD
where date_format(CREATED_DATE, '%Y-%m-%d') = '2022-10-05'
order by BOARD_ID desc

 

๋ฐ˜์‘ํ˜•