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

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL Lv.4 ๋ฌธ์ œํ’€์ด ์ •๋‹ต ๋ชจ์Œ (feat. ์ฝ”๋”ฉํ…Œ์ŠคํŠธ)

๋ฌธ์ œ ํ’€์ด ๊ธฐ๊ฐ„ : 24๋…„ 12์›” 27์ผ ~  ์ตœ์‹ ์ˆœ์œผ๋กœ ์ •๋ ฌํ•œ ๋ฌธ์ œ ์ˆœ์„œ์ž…๋‹ˆ๋‹ค  ๋ณดํ˜ธ์†Œ์—์„œ ์ค‘์„ฑํ™”ํ•œ ๋™๋ฌผSELECT I.ANIMAL_ID , I.ANIMAL_TYPE , I.NAMEFROM ANIMAL_INS AS I JOIN ANIMAL_OUTS AS O ON I.ANIMAL_ID = O.ANIMAL_IDWHERE SEX_UPON_INTAKE REGEXP 'Intact' AND SEX_UPON_OUTCOME REGEXP 'Spayed|Neutered'ORDER BY ANIMAL_ID ์ž…์–‘ ์‹œ๊ฐ ๊ตฌํ•˜๊ธฐ(2)WITH RECURSIVE CTE_HOUR AS ( SELECT 0 AS HOUR UNION ALL SELECT HOUR + 1 FROM CTE_..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL Lv.3 ๋ฌธ์ œํ’€์ด ์ •๋‹ต ๋ชจ์Œ (feat. ์ฝ”๋”ฉํ…Œ์ŠคํŠธ)

๋ฌธ์ œ ํ’€์ด ๊ธฐ๊ฐ„ : 24๋…„ 12์›” 24์ผ ~ 26์ผ ์ตœ์‹ ์ˆœ์œผ๋กœ ์ •๋ ฌํ•œ ๋ฌธ์ œ ์ˆœ์„œ์ž…๋‹ˆ๋‹ค ์—†์–ด์ง„ ๊ธฐ๋ก ์ฐพ๊ธฐSELECT O.ANIMAL_ID , O.NAMEFROM ANIMAL_OUTS AS O LEFT JOIN ANIMAL_INS AS I ON O.ANIMAL_ID = I.ANIMAL_IDWHERE I.ANIMAL_ID IS NULLORDER BY ANIMAL_ID ์žˆ์—ˆ๋Š”๋ฐ์š” ์—†์—ˆ์Šต๋‹ˆ๋‹คSELECT I.ANIMAL_ID , I.NAMEFROM ANIMAL_INS AS I JOIN ANIMAL_OUTS AS O ON I.ANIMAL_ID = O.ANIMAL_IDWHERE I.DATETIME > O.DATETIME -- ๋ณดํ˜ธ์‹œ์ž‘์ผ > ์ž…์–‘์ผ (๋ณดํ˜ธ ์‹œ์ž‘์ผ๋ณด๋‹ค ์ž…์–‘์ผ์ด ๋”..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL Lv.2 ๋ฌธ์ œํ’€์ด ์ •๋‹ต ๋ชจ์Œ (feat. ์ฝ”๋”ฉํ…Œ์ŠคํŠธ)

๋ฌธ์ œ ํ’€์ด ๊ธฐ๊ฐ„ : 24๋…„ 12์›” 20์ผ ~ 23์ผ ์ตœ์‹ ์ˆœ์œผ๋กœ ์ •๋ ฌํ•œ ๋ฌธ์ œ ์ˆœ์„œ์ž…๋‹ˆ๋‹ค ์ตœ์†Ÿ๊ฐ’ ๊ตฌํ•˜๊ธฐSELECT MIN(DATETIME) AS ์‹œ๊ฐ„FROM ANIMAL_INS ๊ณ ์–‘์ด์™€ ๊ฐœ๋Š” ๋ช‡ ๋งˆ๋ฆฌ ์žˆ์„๊นŒSELECT ANIMAL_TYPE , COUNT(*) AS countFROM ANIMAL_INSGROUP BY ANIMAL_TYPEORDER BY ANIMAL_TYPE ๋™๋ช… ๋™๋ฌผ ์ˆ˜ ์ฐพ๊ธฐSELECT NAME , COUNT (NAME) AS COUNTFROM ANIMAL_INSGROUP BY NAMEHAVING COUNT >= 2ORDER BY NAMECOUNT(NAME) = COUNT(*) ์ด์ง€๋งŒ, NAME์ด๋ผ๊ณ  ํŠน์ • ์ง€์œผ๋ฉด, null ๊ฐ’์„ ์ œ์™ธํ•˜๊ณ  count๋ฅผ ํ•œ๋‹ค  ๋ฃจ์‹œ์™€ ์—˜๋ผ ์ฐพ..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL Lv.1 ๋ฌธ์ œํ’€์ด ์ •๋‹ต ๋ชจ์Œ (feat. ์ฝ”๋”ฉํ…Œ์ŠคํŠธ)

๋ฌธ์ œ ํ’€์ด ๊ธฐ๊ฐ„ : 24๋…„ 12์›” 17์ผ ~ 19์ผ  ์ตœ์‹ ์ˆœ์œผ๋กœ ์ •๋ ฌํ•œ ๋ฌธ์ œ ์ˆœ์„œ์ž…๋‹ˆ๋‹ค ๋ชจ๋“  ๋ ˆ์ฝ”๋“œ ์กฐํšŒํ•˜๊ธฐ SELECT *FROM ANIMAL_INSORDER BY ANIMAL_ID ASC; ์—ญ์ˆœ ์ •๋ ฌํ•˜๊ธฐSELECT NAME, DATETIMEFROM ANIMAL_INSORDER BY ANIMAL_ID DESC; ์•„ํ”ˆ ๋™๋ฌผ ์ฐพ๊ธฐSELECT ANIMAL_ID, NAMEFROM ANIMAL_INSWHERE INTAKE_CONDITION = 'Sick'ORDER BY ANIMAL_ID; ์–ด๋ฆฐ ๋™๋ฌผ ์ฐพ๊ธฐSELECT ANIMAL_ID, NAMEFROM ANIMAL_INSWHERE INTAKE_CONDITION != 'Aged'ORDER BY ANIMAL_ID; ์ด๋ฆ„์ด ์—†..

Copy