SELECT bl.name location,COUNT(DISTINCT p.category_id) category_count,COUNT(DISTINCT p.brand_id) brand_count,SUM(t.final_total) revenue FROM business_locations bl JOIN transactions t ON bl.id=t.location_id JOIN transaction_sell_lines tsl ON t.id=tsl.transaction_id JOIN products p ON tsl.product_id=p.id WHERE t.type="sell" GROUP BY bl.id,bl.name ORDER BY revenue DESC;