SELECT HOUR(t.transaction_date) hour,COUNT(DISTINCT t.contact_id) customers,COUNT(t.id) transactions,COUNT(t.id)/COUNT(DISTINCT t.contact_id) visits_per_customer FROM transactions t WHERE t.type="sell" GROUP BY HOUR(t.transaction_date) ORDER BY visits_per_customer DESC;