SELECT pr.rack display_location,COUNT(t.id) transactions,SUM(tsl.quantity) units FROM product_racks pr JOIN products p ON pr.product_id=p.id JOIN transaction_sell_lines tsl ON p.id=tsl.product_id JOIN transactions t ON tsl.transaction_id=t.id WHERE t.type="sell" GROUP BY pr.rack ORDER BY units DESC;