SQL 알고리즘 코드카타

SQL 알고리즘 코드카타 12일차(1) 26.01.10(토)

nom_de_plume 2026. 1. 10. 14:13

부제:

자동차 종류 별 특정 옵션이 포함된 자동차 수 구하기, 레벨 2

 

1. 문제 링크:https://school.programmers.co.kr/learn/courses/30/lessons/151137
2. 정답 코드: 

SELECT
    car_type,
    count(car_type) as cars
from car_rental_company_car
where options like "%통풍시트%" or options like "%열선시트%" or options like "%가죽시트%"
group by car_type
order by car_type


3. 오류 상황:

SELECT
    car_type,
    count(car_type) as cars
from car_rental_company_car
where options in ("%통풍시트%", "%열선시트%","%가죽시트%")
group by car_type
order by car_type

=> 아무것도 출력 안되는 오류 발생
4. 시도 방법: in() 제거 후 like 활용
5. 최종 문제 해결 방법: where문에서 like문을 통해 조건 하나씩 나누고 or로 이어붙여준다.