특정 물고기를 잡은 총 수 구하기

김인범's avatar
Dec 29, 2024
특정 물고기를 잡은 총 수 구하기

문제

💡
notion image

쿼리문

select count(*) as fish_count from fish_info as fi inner join fish_name_info as fn on fi.fish_type = fn.fish_type where fn.fish_name in ('BASS','SNAPPER');
 
문제가 조금 깁니다.
해당 문제는 fish_info 테이블fish_name_info 테이블 2개의 테이블을 사용해야 합니다.
(join 필요)
 
컬럼명은 fish_count로 명시해야한다고 합니다.
두 테이블의 공통된 컬럼인 fish_type을 통해 정보를 결합하여 조회해야 합니다.
on fish_info.fish_type = fish_name_info.fish_type
 
where 절에서는 생선 이름이 ‘BASS'와 'SNAPPER' 인 것들을 조회해야합니다.
where fish_name_info.fish_name in ('BASS','SNAPPER');
 
Share article

taker