문제 정답 SELECT USER_ID, NICKNAME, CONCAT_WS(' ', CITY, STREET_ADDRESS1, STREET_ADDRESS2) AS 전체주소, CONCAT_WS('-', SUBSTRING(TLNO, 1, 3), SUBSTRING(TLNO, 4, 4), SUBSTRING(TLNO, 8, 4)) AS 전화번호 FROM USED_GOODS_BOARD AS A JOIN USED_GOODS_USER AS B ON A.WRITER_ID = B.USER_ID GROUP BY WRITER_ID HAVING COUNT(WRITER_ID) >= 3 ORDER BY USER_ID DESC
문제 정답 SELECT HISTORY_ID, CAR_ID, DATE_FORMAT(START_DATE, '%Y-%m-%d'), DATE_FORMAT(END_DATE, '%Y-%m-%d'), CASE WHEN DATEDIFF(END_DATE, START_DATE) + 1 >= 30 THEN '장기 대여' ELSE '단기 대여' END RENT_TYPE FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY WHERE START_DATE LIKE '2022-09%' ORDER BY HISTORY_ID DESC
문제 정답 SELECT CAR_ID, ROUND(AVG(DATEDIFF(END_DATE, START_DATE) + 1), 1) AS AVERAGE_DURATION FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY GROUP BY CAR_ID HAVING AVG(DATEDIFF(END_DATE, START_DATE) + 1) >= 7 ORDER BY AVERAGE_DURATION DESC, CAR_ID DESC
문제 정답 SELECT BOARD_ID, WRITER_ID, TITLE, PRICE, CASE WHEN STATUS = 'SALE' THEN '판매중' WHEN STATUS = 'RESERVED' THEN '예약중' WHEN STATUS = 'DONE' THEN '거래완료' END STATUS FROM USED_GOODS_BOARD WHERE CREATED_DATE LIKE '2022-10-05' ORDER BY BOARD_ID DESC
문제 정답 SELECT WAREHOUSE_ID, WAREHOUSE_NAME, ADDRESS, IFNULL(FREEZER_YN, 'N') AS FREEZER_YN FROM FOOD_WAREHOUSE WHERE WAREHOUSE_NAME LIKE '%경기%' ORDER BY WAREHOUSE_ID