๐ซ ๋ฌธ์
๐ซ 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)