SELECT CASE WHEN c.total_rp>0 THEN "Loyalty Member" ELSE "Non-Member" END status,COUNT(DISTINCT c.id) customers,AVG(t.final_total) avg_transaction,COUNT(t.id)/COUNT(DISTINCT c.id) purchase_frequency FROM contacts c JOIN transactions t ON c.id=t.contact_id WHERE t.type="sell" GROUP BY CASE WHEN c.total_rp>0 THEN "Loyalty Member" ELSE "Non-Member" END;