Notice
Recent Posts
Recent Comments
Link
«   2026/02   »
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
Tags
more
Archives
Today
Total
관리 메뉴

희동이네

[프로그래머스] 자동차 대여 기록에서 대여중 / 대여 가능 여부 구분하기 본문

Oracle

[프로그래머스] 자동차 대여 기록에서 대여중 / 대여 가능 여부 구분하기

희동누나 2023. 11. 25. 01:07
select car_id, 
    case 
        when car_id in 
            (select car_id
            from CAR_RENTAL_COMPANY_RENTAL_HISTORY
            where to_char(start_date, 'yyyy-mm-dd') <= '2022-10-16'
            and to_char(end_date, 'yyyy-mm-dd') >= '2022-10-16') then '대여중'
        else '대여 가능'
    end as AVAILABILITY
from CAR_RENTAL_COMPANY_RENTAL_HISTORY
group by car_id
order by car_id desc;