[SQL문제풀기] 특정 물고기를 잡은 총 수 구하기(SELECT)

250108
이나겸's avatar
Jan 08, 2025
[SQL문제풀기] 특정 물고기를 잡은 총 수 구하기(SELECT)
Contents
Q.풀이

Q.

notion image
 
 

풀이

  • on b.fish_type = a.fish_type
    • on : 두 테이블을 결합할 때의 조건 설정 ⇒ fish_type을 기준으로 두 테이블의 데이터 연결
    • fish_info 테이블의 fish_type 컬럼과 fish_name_info 테이블의 fish_type 컬럼이 동일한 값일 때만 데이터 결합
  • where fish_name in ('BASS', 'SNAPPER')
    • in : or 조건을 간단하게 표현하는 방법
    • fish_name의 값이 ‘BASS’ 또는 ‘SNAPPER’일 때만 데이터 선택
select count(*) as fish_count from fish_info as b join fish_name_info as a on b.fish_type = a.fish_type where fish_name in ('BASS', 'SNAPPER');
Share article

Nakyeom's Study