SELECT *, OOL+QOH AS TQOH, IF(options REGEXP '=[1-9]',1,0) AS hasoptions FROM products LEFT JOIN _catalog USING(SKU) LEFT JOIN tmp_bestseller_category USING(SKU) WHERE NOT sale AND products.SKU <> 'ZZZ001' AND PUB AND (DIS=0 OR (DIS=1 AND (QOH>0 OR options REGEXP '=[1-9]'))) GROUP BY products.SKU ORDER BY subtotal DESC LIMIT 0,12

Bestsellers