0

Suppose order table: user_id, order_id, created (timestamp), ...

How to calculate average time interval between consequent orders of one user? (How often users create orders?)

4

1 回答 1

1
select case when count(order_id) = 0
       then -1
       else (max(created) - min(created)) / count(order_id)
       end as avg_order_time
from `order`
where user_id = 123
于 2013-06-17T11:02:10.097 回答