SELECT CASE WHEN TIMESTAMPDIFF(YEAR,c.dob,CURRENT_DATE)<25 THEN "18-24" WHEN TIMESTAMPDIFF(YEAR,c.dob,CURRENT_DATE)<35 THEN "25-34" ELSE "35+" END age_group,COUNT(DISTINCT c.id) customers,AVG(t.final_total) avg_purchase FROM contacts c JOIN transactions t ON c.id=t.contact_id WHERE t.type="sell" AND c.dob IS NOT NULL GROUP BY 1 ORDER BY avg_purchase DESC;