250x250
Link
๋‚˜์˜ GitHub Contribution ๊ทธ๋ž˜ํ”„
Loading data ...
Notice
Recent Posts
Recent Comments
๊ด€๋ฆฌ ๋ฉ”๋‰ด

Data Science LAB

[MySQL] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต 16(์ค‘๋ณต์ œ๊ฑฐํ•˜๊ธฐ) ๋ณธ๋ฌธ

๐Ÿ“ Coding Test/MySQL

[MySQL] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต 16(์ค‘๋ณต์ œ๊ฑฐํ•˜๊ธฐ)

ใ…… ใ…œ ใ…” ใ…‡ 2022. 2. 22. 17:15
728x90
๋ฌธ์ œ
ANIMAL_INS ํ…Œ์ด๋ธ”์€ ๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋“ค์–ด์˜จ ๋™๋ฌผ์˜ ์ •๋ณด๋ฅผ ๋‹ด์€ ํ…Œ์ด๋ธ”์ž…๋‹ˆ๋‹ค. 
ANIMAL_INS ํ…Œ์ด๋ธ” ๊ตฌ์กฐ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์œผ๋ฉฐ, 
ANIMAL_ID, ANIMAL_TYPE, DATETIME, INTAKE_CONDITION, NAME, SEX_UPON_INTAKE
๋Š” ๊ฐ๊ฐ ๋™๋ฌผ์˜ ์•„์ด๋””, ์ƒ๋ฌผ ์ข…, ๋ณดํ˜ธ ์‹œ์ž‘์ผ, ๋ณดํ˜ธ ์‹œ์ž‘ ์‹œ ์ƒํƒœ, ์ด๋ฆ„, ์„ฑ๋ณ„ ๋ฐ ์ค‘์„ฑํ™” ์—ฌ๋ถ€๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.


๋™๋ฌผ ๋ณดํ˜ธ์†Œ์— ๋“ค์–ด์˜จ ๋™๋ฌผ์˜ ์ด๋ฆ„์€ ๋ช‡ ๊ฐœ์ธ์ง€ ์กฐํšŒํ•˜๋Š” SQL ๋ฌธ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”. ์ด๋•Œ ์ด๋ฆ„์ด NULL์ธ ๊ฒฝ์šฐ๋Š” ์ง‘๊ณ„ํ•˜์ง€ ์•Š์œผ๋ฉฐ ์ค‘๋ณต๋˜๋Š” ์ด๋ฆ„์€ ํ•˜๋‚˜๋กœ ์นฉ๋‹ˆ๋‹ค.

 

 

 

 

 

 

 

์˜ˆ์‹œ

 

 

 

 

 

 

 

 

๋ฌธ์ œ ํ’€์ด
SELECT COUNT (DISTINCT NAME) AS COUNT
FROM ANIMAL_INS
WHERE NAME IS NOT NULL

COUNT (DISTINCT [์ปฌ๋Ÿผ๋ช…]) ์„ ์‚ฌ์šฉํ•˜๋ฉด ์ค‘๋ณต ์—†์ด ์นด์šดํŠธ๋ฅผ ํ•  ์ˆ˜ ์žˆ๋‹ค. 

๋น„์–ด์žˆ์ง€ ์•Š์€ ๋ฐ์ดํ„ฐ ์ค‘ ์ค‘๋ณต์„ ์ œ๊ฑฐํ•ด์•ผ ํ•˜๋ฏ€๋กœ

WHERE [์ปฌ๋Ÿผ๋ช…] IS NOT NULL์„ ์ถ”๊ฐ€ํ•œ๋‹ค. 

728x90
Comments