티스토리 뷰

https://school.programmers.co.kr/learn/courses/30/lessons/157339

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

with base as (
select 
    car_id
    , max(if(date('2022-11-01') between start_date and end_date
            or date('2022-11-30') between start_date and end_date, 1, 0)) as con
from CAR_RENTAL_COMPANY_RENTAL_HISTORY
group by 1
)
, base2 as (
select
    distinct a.car_id
    , a.car_type
    , a.daily_fee
from CAR_RENTAL_COMPANY_CAR a
left join base b on a.car_id = b.car_id
where (a.car_type = '세단' or a.car_type = 'SUV')
    and (b.con = 0 or b.car_id is null)
)

select
    a.car_id
    , a.car_type
    , floor(a.DAILY_FEE*(1-b.DISCOUNT_RATE/100)*30) as FEE
from base2 a
join CAR_RENTAL_COMPANY_DISCOUNT_PLAN b on a.car_type = b.car_type
    and b.DURATION_TYPE = '30일 이상'
where a.DAILY_FEE*(1-b.DISCOUNT_RATE/100)*30 between 500000 and 2000000
order by 3 desc, 2, 1 desc
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함