SELECT DATE_FORMAT(t.transaction_date,"%Y-%m") month,COUNT(DISTINCT t.contact_id) new_customers,SUM(t.final_total) revenue,SUM(t.final_total)/COUNT(DISTINCT t.contact_id) acquisition_cost FROM transactions t WHERE t.type="sell" AND t.contact_id NOT IN (SELECT contact_id FROM transactions WHERE type="sell" AND transaction_date < t.transaction_date) GROUP BY DATE_FORMAT(t.transaction_date,"%Y-%m") ORDER BY month;