[프로그래머스 SQL 고득점 Kit] String, Date: 자동차 평균 대여 기간 구하기

jieunee·2023년 4월 1일
0

🤔 문제


✅ 정답

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
profile
Back-End Developer 🌱

0개의 댓글