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,prodescription prodescription, discount as discountx,minimumstep as step,minquantity as qquantity, retailprice, activity, vatid,realcode as prodcode,pricesid, price, specialprice, CASE WHEN (SELECT COUNT(checkcode) FROM vlachostoolsgr.[index] WHERE (checkcode = products.checkcode)) > 1 THEN 1 WHEN minquantity > 1 THEN 2 ELSE 0 END AS counter, (SELECT TOP (1) foto1 FROM [index] WHERE (checkcode = products.checkcode and [index].foto1 <> '' ) ORDER BY myaa) AS foto1, checkcode, desc1, desc2, CASE WHEN discount > 0 THEN 1 WHEN (discount = 0) THEN 0 ELSE 0 END AS ratio FROM v_products products where replace(replace(desc1,'/','_'),'&','_') like '%#ΓΑΝΤΙΑ#%' and replace(replace(desc2,'/','_'),'&','_') like '%#ΓΑΝΤΙΑ ΔΕΡΜΑΤΟΠΑΝΙΝΑ#%' and activity=1 and onlylogged=0 order by menuid, products.prodid, secprodid, newsort, ordervalue, taksinomisi