์ƒ์„ธ ์ปจํ…์ธ 

๋ณธ๋ฌธ ์ œ๋ชฉ

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์ค‘์„ฑํ™” ์—ฌ๋ถ€ ํŒŒ์•…ํ•˜๊ธฐ (String, Date/Oracle(SQL))

PROGRAMMING/Database

by koharin 2021. 3. 3. 18:08

๋ณธ๋ฌธ

728x90
๋ฐ˜์‘ํ˜•

๐Ÿ’ป Oracle ์ œ์ถœ์ฝ”๋“œ


SELECT ANIMAL_ID, NAME, (CASE WHEN SEX_UPON_INTAKE NOT LIKE '%Intact%' THEN 'O' ELSE 'X' END)
FROM ANIMAL_INS
ORDER BY ANIMAL_ID;
  • ANIMAL_INS ํ…Œ์ด๋ธ”์—์„œ SEX_UPON_INTAKE๊ฐ€ Intact๊ฐ€ ์•„๋‹ˆ๋ฉด, ์ฆ‰ ์ค‘์„ฑํ™”ํ–ˆ์œผ๋ฉด('Neutered' ๋˜๋Š” 'Spayed') 'O'๋ฅผ ์ถœ๋ ฅํ•˜๊ณ , ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด 'X'๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
  • ์นผ๋Ÿผ ์ด๋ฆ„์€ ์˜ˆ์‹œ ์ถœ๋ ฅ์ฒ˜๋Ÿผ '์ค‘์„ฑํ™”'๊ฐ€ ์•„๋‹ˆ์–ด๋„ ๋˜๋ฏ€๋กœ ๊ทธ๋ƒฅ SELECT ์‹œ SEX_UPON_INTAKE์— CASE ~ THEN ๋ฌธ์„ ์‚ฌ์šฉํ–ˆ๋‹ค.
728x90
๋ฐ˜์‘ํ˜•

๊ด€๋ จ๊ธ€ ๋”๋ณด๊ธฐ