[SQL문제풀기] 자동차 종류 별 특정 옵션이 포함된 자동차 수 구하기(GROUP BY)

241205
이나겸's avatar
Dec 04, 2024
[SQL문제풀기] 자동차 종류 별 특정 옵션이 포함된 자동차 수 구하기(GROUP BY)
Contents
Q.풀이

Q.

notion image
 
 

풀이

  • like : 비교 연산자, 특정 패턴과 부분적으로 일치하는 값을 찾기 위해 사용
    • % : 와일드 카드, 이 경우 특정 옵션들이 포함된걸 찾아야하기 때문에 ‘%옵션이름%’
  • group by
    • 그룹화
  • order by ~ asc
    • 오름차순 정렬
select car_type, count(*) as cars from car_rental_company_car where options like '%통풍시트%' or options like '%열선시트%' or options like '%가죽시트%' group by car_type order by car_type asc;
Share article

Nakyeom's Study