프로그래머스 SQL GROUP BY 문제 정답 모음

HR·2022년 12월 13일
0
post-thumbnail

성분으로 구분한 아이스크림 총 주문량

SELECT ii.ingredient_type, sum(fh.total_order)
from first_half fh join icecream_info ii
on fh.flavor = ii.flavor
group by ingredient_type
order by sum(fh.total_order) asc

진료과별 총 예약 횟수 출력하기

SELECT mcdp_cd as '진료과코드', count(*) as '5월예약건수'
from appointment
where date_format(apnt_ymd, '%m') = 5
group by mcdp_cd
order by count(*) asc, mcdp_cd asc

고양이와 개는 몇 마리 있을까

SELECT animal_type, count(*) as count
from animal_ins
group by animal_type
having animal_type in ('Cat', 'Dog')
order by animal_type asc

동명 동물 수 찾기

SELECT name, count(*)
from animal_ins
where name is not null
group by name
having count(*)>1
order by name

입양 시각 구하기(1)

SELECT date_format(datetime, '%k') as HOUR, count(*) as COUNT
from animal_outs
group by HOUR
having HOUR between 9 and 19
order by date_format(datetime, '%H') asc

가격대 별 상품 개수 구하기

SELECT floor(price / 10000)*10000 as PRICE_GROUP, count(*) as PRODUCTS
from product
group by floor(price / 10000)
order by PRICE_GROUP

0개의 댓글