-- Distributors with product counts
-- This report shows the number of products per distributor
-- FILTER: {
--   filter: "link",
--   column: "link",
--   "params": {
--         "blank": true,
--         "display": "View Products"
--     }
-- }

SELECT (select name from simplebrsprod.business_location where id=location_id) as name,
       count(*) as products,
       concat('https://simple123.com/distributor/distributors/', location_id, '/products') as link
FROM simplebrsprod.deal_product
GROUP BY location_id
ORDER BY products DESC ;
