부제:
자동차 종류 별 특정 옵션이 포함된 자동차 수 구하기, 레벨 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로 이어붙여준다.
'SQL 알고리즘 코드카타' 카테고리의 다른 글
| SQL 알고리즘 코드카타 12일차(3) 26.01.10(토) (0) | 2026.01.10 |
|---|---|
| SQL 알고리즘 코드카타 12일차(2) 26.01.10(토) (0) | 2026.01.10 |
| SQL 알고리즘 코드카타 11일차(3) 26.01.09(금) (0) | 2026.01.09 |
| SQL 알고리즘 코드카타 11일차(1) 26.01.09(금) (0) | 2026.01.09 |
| SQL 알고리즘 코드카타 10일차(3) 26.01.08(목) (0) | 2026.01.08 |