ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๐Ÿ–ฅ ๋ฌธ์ œ

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

๐Ÿค” ํ’€์ด ๋ฐฉ๋ฒ•

  1. COUNT: ๋™๋ฌผ์˜ ์ด๋ฆ„์ด ๋ช‡ ๊ฐœ์ธ์ง€ ์กฐํšŒํ•œ๋‹ค.
    • SELECT๋ฅผ ํ†ตํ•˜์—ฌ ANIMAL_INS๋ฅผ ์กฐํšŒํ•œ๋‹ค.
    • COUNT๋ฅผ ํ†ตํ•˜์—ฌ NAME์ด ๋ช‡ ๊ฐœ์ธ์ง€ ์กฐํšŒํ•œ๋‹ค.
  2. IS NOT NULL: NAME์ด NULL์ธ ๊ฒฝ์šฐ๋Š” ์ง‘๊ณ„ํ•˜์ง€ ์•Š๋Š”๋‹ค.
  3. DISTINCT: ์ค‘๋ณต๋˜๋Š” ์ด๋ฆ„์€ ํ•˜๋‚˜๋กœ ์นœ๋‹ค.

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป SQL

SELECT COUNT(DISTINCT NAME)
FROM ANIMAL_INS
WHERE NAME IS NOT NULL

'SQL' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[SQL] ์ž…์–‘ ์‹œ๊ฐ ๊ตฌํ•˜๊ธฐ (HOUR)  (0) 2021.02.26
[SQL] ๋™๋ช… ๋™๋ฌผ ์ˆ˜ ์ฐพ๊ธฐ (GROUP BY, HAVING)  (0) 2021.02.26
๋Œ“๊ธ€
๊ณต์ง€์‚ฌํ•ญ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
Total
Today
Yesterday
๋งํฌ
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
๊ธ€ ๋ณด๊ด€ํ•จ