Oracle
[프로그래머스] 자동차 대여 기록에서 대여중 / 대여 가능 여부 구분하기
dearbeany
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;