SELECT bl.name location,p.name product,COUNT(t.id) sales,SUM(tsl.quantity) units 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,p.id,bl.name,p.name ORDER BY units DESC;