ji-0630 / CodingTest

코딩테스트 연습 기록
0 stars 0 forks source link

자동차 평균 대여 기간 구하기 #250

Closed ji-0630 closed 1 year ago

ji-0630 commented 1 year ago

문제 설명

image

ji-0630 commented 1 year ago

나의 풀이

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 AVERAGE_DURATION >= 7
order by AVERAGE_DURATION desc, CAR_ID desc