๐Ÿ’ซ ๋ฌธ์ œ


ย 

๐Ÿ’ซ CODE

SELECT ANIMAL_TYPE, COUNT(*) AS count
FROM ANIMAL_INS
WHERE ANIMAL_TYPE = 'Cat' OR ANIMAL_TYPE = 'Dog'
GROUP BY ANIMAL_TYPE
ORDER BY ANIMAL_TYPE;

ย 

๐Ÿ’ซ ํ’€์ด ์กฐ๊ฑด

1. ๋™๋ฌผ ์ค‘ ๊ณ ์–‘์ด์™€ ๊ฐœ๊ฐ€ ๊ฐ๊ฐ ๋ช‡ ๋งˆ๋ฆฌ์ธ์ง€ ์กฐํšŒ
2. ๊ณ ์–‘์ด๋ฅผ ๊ฐœ๋ณด๋‹ค ๋จผ์ € ์กฐํšŒ

ย 

๐Ÿ’ซ ํ’€์ด

1. SELECT ANIMAL_TYPE, COUNT(*) AS count
  • ๋™๋ฌผ ์ข…๋ฅ˜(ANIMAL_TYPE), COUNT๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ช‡๋งˆ๋ฆฌ์ธ์ง€ ์กฐํšŒ
  • AS๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ COUNT(*)๋ฅผ count๋กœ ๋ณ„์นญ ์ง€์ •
2. WHERE ANIMAL_TYPE = 'Cat' OR ANIMAL_TYPE = 'Dog'
  • ๋™๋ฌผ ์ข…๋ฅ˜(ANIMAL_TYPE)๊ฐ€ 'Cat'์ด๊ฑฐ๋‚˜ 'Dog'์ธ ์ปฌ๋Ÿผ ์กฐํšŒ
3. GROUP BY ANIMAL_TYPE
  • COUNT๋ฅผ ํ• ๋•Œ ANIMAL_TYPE์„ ๊ธฐ์ค€์œผ๋กœ COUNT
4. ORDER BY ANIMAL_TYPE
  • ๋™๋ฌผ ์ข…๋ฅ˜(ANIMAL_TYPE)๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์˜ค๋ฆ„์ฐจ์ˆœ(ASC)

By Dozzing

๋‹ต๊ธ€ ๋‚จ๊ธฐ๊ธฐ

์ด๋ฉ”์ผ ์ฃผ์†Œ๋Š” ๊ณต๊ฐœ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํ•„์ˆ˜ ํ•„๋“œ๋Š” *๋กœ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค