SELECT CRCC.CAR_ID FROM CAR_RENTAL_COMPANY_CAR AS CRCC
JOIN CAR_RENTAL_COMPANY_RENTAL_HISTORY AS CRCRH
ON CRCRH.CAR_ID = CRCC.CAR_ID
WHERE CRCC.CAR_TYPE = '세단' AND CRCRH.START_DATE LIKE '%-10-%'
GROUP BY CRCRH.CAR_ID
ORDER BY CRCC.CAR_ID DESC
다른방식 서브쿼리 1
SELECT CAR_ID
FROM CAR_RENTAL_COMPANY_CAR
WHERE CAR_TYPE = '세단'
AND
CAR_ID IN
(SELECT CAR_ID FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY
WHERE START_DATE LIKE '%-10-%'
)
ORDER BY CAR_ID DESC
다른방식 서브쿼리 2
SELECT CAR_ID
FROM (
SELECT CRCC.CAR_ID
FROM CAR_RENTAL_COMPANY_CAR AS CRCC
JOIN CAR_RENTAL_COMPANY_RENTAL_HISTORY AS CRCRH
ON CRCRH.CAR_ID = CRCC.CAR_ID
WHERE CRCC.CAR_TYPE = '세단' AND CRCRH.START_DATE LIKE '%-10-%'
GROUP BY CRCRH.CAR_ID
) AS Subquery
ORDER BY CAR_ID DESC