SQL/String, Date
[프로그래머스 ORACLE SQL]자동차 평균 대여 기간 구하기★날짜 뺄때는 1을 더하자!
goAhEAd_29
2023. 6. 22. 19:52
728x90
반응형
https://school.programmers.co.kr/learn/courses/30/lessons/157342
SELECT CAR_ID , ROUND(AVG(END_DATE - START_DATE+1 ),1) AS AVERAGE_DURATION
FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY
GROUP BY CAR_ID
HAVING ROUND(AVG(END_DATE - START_DATE+1 ),1) >=7
ORDER BY AVERAGE_DURATION DESC , CAR_ID DESC
==> 날짜간 뺄셈은 1을 더해야 한다!
728x90
반응형