select car_id, if(car_id in (select car_id from CAR_RENTAL_COMPANY_RENTAL_HISTORY
where (START_DATE<='2022-10-16' AND
END_DATE>='2022-10-16')
), '대여중','대여 가능') AS AVAILABILITY from CAR_RENTAL_COMPANY_RENTAL_HISTORY
group by car_id
order by car_id desc;