SELECT cg.name customer_segment,COUNT(DISTINCT p.category_id) preferred_categories,AVG(t.final_total) avg_purchase FROM customer_groups cg JOIN contacts c ON cg.id=c.customer_group_id JOIN transactions t ON c.id=t.contact_id JOIN transaction_sell_lines tsl ON t.id=tsl.transaction_id JOIN products p ON tsl.product_id=p.id WHERE t.type="sell" GROUP BY cg.id,cg.name ORDER BY avg_purchase DESC;