๋ฐ˜์‘ํ˜•

๐Ÿ’ SQL/Sum, Max, Min 6

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][MySQL] ๋ฌผ๊ณ ๊ธฐ ์ข…๋ฅ˜ ๋ณ„ ๋Œ€์–ด ์ฐพ๊ธฐ (level3)

https://school.programmers.co.kr/learn/courses/30/lessons/293261 ํ”„๋กœ๊ทธ๋ž˜๋จธ์ŠคSW๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ ํ‰๊ฐ€, ๊ต์œก, ์ฑ„์šฉ๊นŒ์ง€ Total Solution์„ ์ œ๊ณตํ•˜๋Š” ๊ฐœ๋ฐœ์ž ์„ฑ์žฅ์„ ์œ„ํ•œ ๋ฒ ์ด์Šค์บ ํ”„programmers.co.kr ๋ฌธ์ œ๋ฌผ๊ณ ๊ธฐ ์ข…๋ฅ˜ ๋ณ„๋กœ ๊ฐ€์žฅ ํฐ ๋ฌผ๊ณ ๊ธฐ์˜ ID, ๋ฌผ๊ณ ๊ธฐ ์ด๋ฆ„, ๊ธธ์ด๋ฅผ ์ถœ๋ ฅํ•˜๋Š” SQL ๋ฌธ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”.๋ฌผ๊ณ ๊ธฐ์˜ ID ์ปฌ๋Ÿผ๋ช…์€ ID, ์ด๋ฆ„ ์ปฌ๋Ÿผ๋ช…์€ FISH_NAME, ๊ธธ์ด ์ปฌ๋Ÿผ๋ช…์€ LENGTH๋กœ ํ•ด์ฃผ์„ธ์š”. ๊ฒฐ๊ณผ๋Š” ๋ฌผ๊ณ ๊ธฐ์˜ ID์— ๋Œ€ํ•ด ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌํ•ด์ฃผ์„ธ์š”. ๋‹จ, ๋ฌผ๊ณ ๊ธฐ ์ข…๋ฅ˜๋ณ„ ๊ฐ€์žฅ ํฐ ๋ฌผ๊ณ ๊ธฐ๋Š” 1๋งˆ๋ฆฌ๋งŒ ์žˆ์œผ๋ฉฐ 10cm ์ดํ•˜์˜ ๋ฌผ๊ณ ๊ธฐ๊ฐ€ ๊ฐ€์žฅ ํฐ ๊ฒฝ์šฐ๋Š” ์—†์Šต๋‹ˆ๋‹ค. ํ’€์ดselect i.ID, n.FISH_NAME, i.LENGTHfrom FISH_..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][SQL] ์žก์€ ๋ฌผ๊ณ ๊ธฐ ์ค‘ ๊ฐ€์žฅ ํฐ ๋ฌผ๊ณ ๊ธฐ์˜ ๊ธธ์ด ๊ตฌํ•˜๊ธฐ

https://school.programmers.co.kr/learn/courses/30/lessons/298515 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.programmers.co.kr ๋ฌธ์ œFISH_INFO ํ…Œ์ด๋ธ”์—์„œ ์žก์€ ๋ฌผ๊ณ ๊ธฐ ์ค‘ ๊ฐ€์žฅ ํฐ ๋ฌผ๊ณ ๊ธฐ์˜ ๊ธธ์ด๋ฅผ 'cm' ๋ฅผ ๋ถ™์—ฌ ์ถœ๋ ฅํ•˜๋Š” SQL ๋ฌธ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”.์ด ๋•Œ ์ปฌ๋Ÿผ๋ช…์€ 'MAX_LENGTH' ๋กœ ์ง€์ •ํ•ด์ฃผ์„ธ์š”.ํ’€์ดselect concat(max(LENGTH),"cm") as MAX_LENGTHfrom FISH_INFO

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][SQL] ์กฐ๊ฑด์— ๋งž๋Š” ์•„์ดํ…œ๋“ค์˜ ๊ฐ€๊ฒฉ์˜ ์ดํ•ฉ ๊ตฌํ•˜๊ธฐ

https://school.programmers.co.kr/learn/courses/30/lessons/273709 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.programmers.co.kr ๋ฌธ์ œITEM_INFO ํ…Œ์ด๋ธ”์—์„œ ํฌ๊ท€๋„๊ฐ€ 'LEGEND'์ธ ์•„์ดํ…œ๋“ค์˜ ๊ฐ€๊ฒฉ์˜ ์ดํ•ฉ์„ ๊ตฌํ•˜๋Š” SQL๋ฌธ์„ ์ž‘์„ฑํ•ด ์ฃผ์„ธ์š”. ์ด๋•Œ ์ปฌ๋Ÿผ๋ช…์€ 'TOTAL_PRICE'๋กœ ์ง€์ •ํ•ด ์ฃผ์„ธ์š”. ํ’€์ดselect sum(PRICE) as TOTAL_PRICEfrom ITEM_INFOwhere RARITY = 'LEGEND'

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

https://school.programmers.co.kr/learn/courses/30/lessons/131115 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr -- ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š” SELECT * from FOOD_PRODUCT where PRICE = ( select max(PRICE) from FOOD_PRODUCT )

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL ๊ณ ๋“์  Kit: ๊ฐ€์žฅ ๋น„์‹ผ ์ƒํ’ˆ ๊ตฌํ•˜๊ธฐ

https://school.programmers.co.kr/learn/courses/30/lessons/131697 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr SELECT max(PRICE) from PRODUCT

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] SQL ๊ณ ๋“์  kit: Sum, Max, Min (ANIMAL_INS ํ…Œ์ด๋ธ”)

https://school.programmers.co.kr/learn/courses/30/parts/17042 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr ANIMAL_INS ํ…Œ์ด๋ธ”์€ ๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋“ค์–ด์˜จ ๋™๋ฌผ์˜ ์ •๋ณด๋ฅผ ๋‹ด์€ ํ…Œ์ด๋ธ”์ž…๋‹ˆ๋‹ค. ANIMAL_INS ํ…Œ์ด๋ธ” ๊ตฌ์กฐ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์œผ๋ฉฐ, ANIMAL_ID, ANIMAL_TYPE, DATETIME, INTAKE_CONDITION, NAME, SEX_UPON_INTAKE๋Š” ๊ฐ๊ฐ ๋™๋ฌผ์˜ ์•„์ด๋””, ์ƒ๋ฌผ ์ข…, ๋ณดํ˜ธ ์‹œ์ž‘์ผ, ๋ณดํ˜ธ ์‹œ์ž‘ ์‹œ ์ƒํƒœ, ์ด๋ฆ„, ์„ฑ๋ณ„ ๋ฐ ์ค‘์„ฑํ™” ์—ฌ๋ถ€๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. ANIMAL_ID VAR..

๋ฐ˜์‘ํ˜•