SELECT c.name,COUNT(t.id) transactions,AVG(t.final_total) avg_transaction,COUNT(t.id)/DATEDIFF(MAX(t.transaction_date),MIN(t.transaction_date)) frequency FROM contacts c JOIN transactions t ON c.id=t.contact_id WHERE t.type="sell" GROUP BY c.id,c.name HAVING COUNT(t.id)>1 ORDER BY frequency DESC;