코딩테스트

[프로그래머스][SQL] 특정 물고기 잡은 총 수 구하기, 월별 잡은 물고기 수 구하기, 물고기 종류 별 잡은 수 구하기

도도o 2024. 9. 29. 17:28

FISH_INFO 관련 SQL 문제 - 프로그래머스 lv2

 

 

 

 

 

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

 

제출한 답안

select count(*) as fish_count
from fish_info
where fish_type in (select fish_type from fish_name_info
                   where fish_name in ('BASS', 'SNAPPER'))

 

 

 

 

월별 잡은 물고기 수 구하기

 

제출한 답안

select count(*) as FISH_COUNT, month(time) as MONTH
from fish_info
group by MONTH
order by MONTH

 

 

 

 

물고기 종류 별 잡은 수 구하기

 

제출한 답안

select count(A.id) as fish_count, B.fish_name
from fish_info A, fish_name_info B
where A.fish_type = B.fish_type
group by B.fish_name
order by fish_count desc