SELECT bl.name location,COUNT(t.id) transactions,AVG(TIMESTAMPDIFF(MINUTE,t.created_at,t.updated_at)) avg_service_time,COUNT(DISTINCT t.contact_id) unique_customers FROM business_locations bl JOIN transactions t ON bl.id=t.location_id WHERE t.type="sell" GROUP BY bl.id,bl.name ORDER BY avg_service_time;