๋ฐ˜์‘ํ˜•

๐Ÿ’ SQL/Is Null 8

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][SQL] ์—…๊ทธ๋ ˆ์ด๋“œ ํ•  ์ˆ˜ ์—†๋Š” ์•„์ดํ…œ ๊ตฌํ•˜๊ธฐ (level3)

https://school.programmers.co.kr/learn/courses/30/lessons/273712 ํ”„๋กœ๊ทธ๋ž˜๋จธ์ŠคSW๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ ํ‰๊ฐ€, ๊ต์œก, ์ฑ„์šฉ๊นŒ์ง€ Total Solution์„ ์ œ๊ณตํ•˜๋Š” ๊ฐœ๋ฐœ์ž ์„ฑ์žฅ์„ ์œ„ํ•œ ๋ฒ ์ด์Šค์บ ํ”„programmers.co.kr ๋ฌธ์ œ๋” ์ด์ƒ ์—…๊ทธ๋ ˆ์ด๋“œํ•  ์ˆ˜ ์—†๋Š” ์•„์ดํ…œ์˜ ์•„์ดํ…œ ID(ITEM_ID), ์•„์ดํ…œ ๋ช…(ITEM_NAME), ์•„์ดํ…œ์˜ ํฌ๊ท€๋„(RARITY)๋ฅผ ์ถœ๋ ฅํ•˜๋Š” SQL ๋ฌธ์„ ์ž‘์„ฑํ•ด ์ฃผ์„ธ์š”.์ด๋•Œ ๊ฒฐ๊ณผ๋Š” ์•„์ดํ…œ ID๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌํ•ด ์ฃผ์„ธ์š”. ํ’€์ดselect ITEM_ID, ITEM_NAME, RARITYfrom ITEM_INFOwhere ITEM_ID in ( select p.ITEM_ID as no_more_upgrade ..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][SQL] ์žก์€ ๋ฌผ๊ณ ๊ธฐ์˜ ํ‰๊ท  ๊ธธ์ด ๊ตฌํ•˜๊ธฐ (293259)

https://school.programmers.co.kr/learn/courses/30/lessons/293259 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.programmers.co.kr ๋ฌธ์ œ์žก์€ ๋ฌผ๊ณ ๊ธฐ์˜ ํ‰๊ท  ๊ธธ์ด๋ฅผ ์ถœ๋ ฅํ•˜๋Š” SQL๋ฌธ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”.ํ‰๊ท  ๊ธธ์ด๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ์ปฌ๋Ÿผ ๋ช…์€ AVERAGE_LENGTH๋กœ ํ•ด์ฃผ์„ธ์š”.ํ‰๊ท  ๊ธธ์ด๋Š” ์†Œ์ˆ˜์  3์งธ์ž๋ฆฌ์—์„œ ๋ฐ˜์˜ฌ๋ฆผํ•˜๋ฉฐ, 10cm ์ดํ•˜์˜ ๋ฌผ๊ณ ๊ธฐ๋“ค์€ 10cm ๋กœ ์ทจ๊ธ‰ํ•˜์—ฌ ํ‰๊ท  ๊ธธ์ด๋ฅผ ๊ตฌํ•ด์ฃผ์„ธ์š”. ํ’€์ดselect round(avg(len), 2) as AVERAGE_LENGTHfrom ( select case when LEN..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][SQL] ROOT ์•„์ดํ…œ ๊ตฌํ•˜๊ธฐ

https://school.programmers.co.kr/learn/courses/30/lessons/273710 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.programmers.co.kr ๋ฌธ์ œROOT ์•„์ดํ…œ์„ ์ฐพ์•„ ์•„์ดํ…œ ID(ITEM_ID), ์•„์ดํ…œ ๋ช…(ITEM_NAME)์„ ์ถœ๋ ฅํ•˜๋Š” SQL๋ฌธ์„ ์ž‘์„ฑํ•ด ์ฃผ์„ธ์š”. ์ด๋•Œ, ๊ฒฐ๊ณผ๋Š” ์•„์ดํ…œ ID๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌํ•ด ์ฃผ์„ธ์š”.ํ’€์ดselect i.ITEM_ID, i.ITEM_NAMEfrom ITEM_INFO i join ITEM_TREE t on i.ITEM_ID = t.ITEM_IDwhere t.PARENT_ITEM_ID is NULLo..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL ๊ณ ๋“์  Kit: NULL ์ฒ˜๋ฆฌํ•˜๊ธฐ

https://school.programmers.co.kr/learn/courses/30/lessons/59410 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr -- ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š” SELECT ANIMAL_TYPE, ifnull(NAME, 'No name') as NAME, SEX_UPON_INTAKE from ANIMAL_INS

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL ๊ณ ๋“์  Kit : ๊ฒฝ๊ธฐ๋„์— ์œ„์น˜ํ•œ ์‹ํ’ˆ์ฐฝ๊ณ  ๋ชฉ๋ก ์ถœ๋ ฅํ•˜๊ธฐ

https://school.programmers.co.kr/learn/courses/30/lessons/131114 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr -- ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š” SELECT WAREHOUSE_ID, WAREHOUSE_NAME, ADDRESS, if(FREEZER_YN is NULL, 'N', FREEZER_YN) as FREEZER_YN FROM FOOD_WAREHOUSE WHERE ADDRESS LIKE "๊ฒฝ๊ธฐ๋„%" ORDER by WAREHOUSE_ID asc

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL ๊ณ ๋“์  Kit : ์ด๋ฆ„์ด ์—†๋Š” ๋™๋ฌผ์˜ ์•„์ด๋””

https://school.programmers.co.kr/learn/courses/30/lessons/59039 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr -- ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š” SELECT ANIMAL_ID from ANIMAL_INS where NAME is null order by ANIMAL_ID

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL ๊ณ ๋“์  Kit : ๋‚˜์ด ์ •๋ณด๊ฐ€ ์—†๋Š” ํšŒ์› ์ˆ˜ ๊ตฌํ•˜๊ธฐ

https://school.programmers.co.kr/learn/courses/30/lessons/131528 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr -- ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š” SELECT COUNT(USER_ID) AS USERS FROM USER_INFO WHERE AGE IS NULL

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL ๊ณ ๋“์  Kit: ์ด๋ฆ„์ด ์žˆ๋Š” ๋™๋ฌผ์˜ ์•„์ด๋””

https://school.programmers.co.kr/learn/courses/30/lessons/59407 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr -- ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š” SELECT ANIMAL_ID FROM ANIMAL_INS WHERE NAME IS NOT NULL

๋ฐ˜์‘ํ˜•