SELECT c.name,COUNT(t.id) transactions,SUM(t.final_total) total_spent,AVG(t.final_total) avg_transaction FROM contacts c JOIN transactions t ON c.id=t.contact_id WHERE t.type="sell" GROUP BY c.id,c.name ORDER BY total_spent DESC;