문제
https://school.programmers.co.kr/learn/courses/30/lessons/157339
풀이
SELECT D.car_id, D.car_type, round((1-P.DISCOUNT_RATE/100)*30 * D.daily_fee) as FEE
FROM CAR_RENTAL_COMPANY_DISCOUNT_PLAN P
JOIN
(SELECT C.car_id, C.car_type, C.daily_fee
FROM CAR_RENTAL_COMPANY_CAR C
JOIN
(select car_id
FROM CAR_RENTAL_COMPANY_CAR
where car_id not in(
(select distinct car_id
from CAR_RENTAL_COMPANY_RENTAL_HISTORY
where ('2022-11-01' between start_date and end_date) or ('2022-11-30' between start_date and end_date)) )
)B
ON B.car_id=C.car_id
WHERE CAR_TYPE="SUV" OR CAR_TYPE="세단")D
ON D.car_type=P.car_type
WHERE P.DURATION_TYPE LIKE "30%"
AND 500000 <= round((1-P.DISCOUNT_RATE/100)*30 * D.daily_fee)
AND round((1-P.DISCOUNT_RATE/100)*30 * D.daily_fee) < 2000000
order by fee desc, car_type asc, car_id desc;
'SQLD' 카테고리의 다른 글
오라클 무한로딩(프로시저 사용할 때) (0) | 2023.02.21 |
---|---|
[프로그래머스 SQL고득점 키트 String, Date]DATETIME에서 DATE로 형 변환 (0) | 2023.02.09 |
[프로그래머스 SQL고득점 키트 String, Date]오랜 기간 보호한 동물(2) (0) | 2023.02.09 |
[프로그래머스 SQL고득점 키트 String, Date]중성화 여부 파악하기 (0) | 2023.02.09 |
[프로그래머스 SQL고득점 키트 String, Date]DATETIME에서 DATE로 형 변환 (0) | 2023.02.09 |
댓글