SELECT u.first_name staff_name,COUNT(t.id) transactions,SUM(t.final_total) total_sales,AVG(t.final_total) avg_sale FROM users u JOIN transactions t ON u.id=t.created_by WHERE t.type="sell" GROUP BY u.id,u.first_name ORDER BY total_sales DESC;