Hi All,
Had a quick question, do we know why we have count(*)-1 in the denominator when we calculate average days between orders for each customers in SQL?
select CustomerID
, cast(DATEDIFF(dd, min(OrderDate), max(OrderDate)) as decimal) / (count() - 1) as [Avg_Day]
from Orders
group by CustomerID
having count() > 1
Thanks,