문제 정답 SELECT CAR_ID, CASE WHEN CAR_ID IN ( SELECT CAR_ID FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY WHERE '2022-10-16' BETWEEN START_DATE AND END_DATE ) THEN '대여중' ELSE '대여 가능' END AS AVAILABILITY FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY GROUP BY CAR_ID ORDER BY CAR_ID DESC
문제 정답 SELECT CAR_TYPE, COUNT(CAR_TYPE) AS CARS FROM CAR_RENTAL_COMPANY_CAR WHERE OPTIONS LIKE '%통풍시트%' OR OPTIONS LIKE '%열선시트%' OR OPTIONS LIKE '%가죽시트%' GROUP BY CAR_TYPE ORDER BY CAR_TYPE
문제 정답 SELECT A.CATEGORY, SUM(B.SALES) AS TOTAL_SALES FROM BOOK AS A JOIN BOOK_SALES AS B ON A.BOOK_ID = B.BOOK_ID WHERE B.SALES_DATE LIKE '%2022-01%' GROUP BY A.CATEGORY ORDER BY A.CATEGORY
문제 정답 SELECT MONTH(START_DATE) AS MONTH, CAR_ID, COUNT(*) AS RECORDS FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY WHERE START_DATE BETWEEN '2022-08-01' AND '2022-10-31' AND CAR_ID IN (SELECT CAR_ID FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY WHERE START_DATE BETWEEN '2022-08-01' AND '2022-10-31' GROUP BY CAR_ID HAVING COUNT(CAR_ID) >= 5) GROUP BY CAR_ID, MONTH(START_DATE) ORDER BY MONTH ASC, CAR_ID DESC
문제 정답 SELECT FOOD_TYPE, REST_ID, REST_NAME, FAVORITES FROM REST_INFO WHERE (FOOD_TYPE, FAVORITES) IN (SELECT FOOD_TYPE, MAX(FAVORITES) FROM REST_INFO GROUP BY FOOD_TYPE) ORDER BY FOOD_TYPE DESC