Chaid:select 0 AS hasdiscount, 0 AS discountqstart1, 0 AS discountqstart2, 0 AS discountqstart3, 0 AS discountqstart4, 0 AS discountqstart5, 0 AS DISCOUNT1, 0 AS DISCOUNT2, 0 AS DISCOUNT3, 0 AS DISCOUNT4, 0 AS DISCOUNT5, products.prodescription, AS discountx, products.minimumstep AS step, products.minquantity AS qquantity, products.retailprice, products.activity, products.vatid, products.realcode AS prodcode, products.pricesid, products.price, products.specialprice, CASE WHEN (SELECT COUNT(checkcode) FROM vlachostoolsgr.[index] WHERE (checkcode = products.checkcode)) > 1 THEN 1 WHEN products.minquantity > 1 THEN 2 ELSE 0 END AS counter, (SELECT TOP (1) foto1 FROM vlachostoolsgr.[index] WHERE (checkcode = products.checkcode and [index].foto1 <> '' ) ORDER BY myaa) AS foto1, products.checkcode, desc1, desc2, CASE WHEN discount > 0 THEN 1 WHEN (discount = 0) THEN 0 ELSE 0 END AS ratio FROM v_products products inner join vlachostoolsgr.[index] i on i.checkcode=products.checkcode where i.prodcode like '%VOYLET%' or i.keywords LIKE '%βουλετ%' or i.keywords LIKE '%VOYLET%' or i.foto1 like '%VOYLET%' or products.keywords LIKE '%βουλετ%' or products.keywords LIKE '%VOYLET%' or lower(products.prodescription) LIKE '%βουλετ%' or lower(products.prodescription) LIKE '%VOYLET%' or lower(i.sizedesc) LIKE '%βουλετ%' or lower(i.sizedesc) LIKE '%VOYLET%' and products.activity=1 order by menuid, products.prodid, secprodid, newsort, ordervalue, taksinomisi