SELECT YEARWEEK(t.transaction_date) week,COUNT(t.id) transactions,COUNT(DISTINCT t.created_by) staff_count,COUNT(t.id)/COUNT(DISTINCT t.created_by) transactions_per_staff FROM transactions t WHERE t.type="sell" GROUP BY YEARWEEK(t.transaction_date) ORDER BY transactions_per_staff DESC;