https://school.programmers.co.kr/learn/courses/30/lessons/157339
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
11월 1일부터 30일까지 예약이 없는 자동차를 조회해야 한다.
SELECT c.car_id, c.car_type, round((c.daily_fee * (100-p.discount_rate) / 100) * 30,0) as fee
from car_rental_company_car c
left join car_rental_company_rental_history h
on c.car_id = h.car_id and h.start_date <= '2022-11-30' and h.end_date >= '2022-11-01'
join car_rental_company_discount_plan p on c.car_type = p.car_type
where (c.car_type = 'SUV' or c.car_type = '세단')
and h.car_id is null
and c.daily_fee * 30 between 500000 and 2000000
and p.duration_type = '30일 이상'
order by fee desc, c.car_type, c.car_id desc
'PROGRAMMERS' 카테고리의 다른 글
[알고리즘 고득점 kit][Level 3] 섬 연결하기 (0) | 2025.02.25 |
---|---|
[SQL 고득점 Kit][GROUP BY] 자동차 대여 기록에서 대여중 / 대여 가능 여부 구분하기 (1) | 2025.02.12 |
[SQL 고득점 Kit][JOIN][Level 5] 상품을 구매한 회원 비율 구하기 (0) | 2025.02.09 |
[SQL 고득점 Kit][JOIN] 없어진 기록 찾기 (0) | 2025.02.02 |
[SQL 고득점 Kit][IS NULL][Level 3] 업그레이드 할 수 없는 아이템 구하기 (1) | 2025.01.27 |