1. 문제 풀이 아이디어
WHERE절과GROUP BY절을 사용하면 문제를 해결할 수 있다.
2. 나의 정답 코드
SELECT animal_type, count(*)
FROM animal_ins
WHERE animal_type IN ('cat','dog')
GROUP BY animal_type
ORDER BY animal_type;3. 정리
WHERE절에서IN키워드를 사용해cat과dog인 데이터를 필터링하고,GROUP BY절로 묶어서COUNT함수를 통해 총 개수를 계산한다. 마지막으로,ORDER BY절로 정렬을 수행한다.
Share article