1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo' at line 85

SELECT DISTINCT p.products_status, p.products_id, p.products_id AS id, p.observaciones, p.attribute_text1, p.attribute_text2, p.attribute_text3, p.products_bundle, p.products_bundle_pvpud_mostrar, p.products_bundle_pvpud, p.sold_in_bundle_only, p.venta_sinstock, IF(p.venta_sinstock > 0 OR p.products_quantity > 0,100,p.venta_sinstock) AS sort_score, p.products_weight, p.tinta_tipo, p.products_image, p.products_image_med, p.products_image_lrg, p.products_image_fullres, p.products_image_sm_1, p.products_image_xl_1, p.products_image_fullres_1, p.products_image_sm_2, p.products_image_xl_2, p.products_image_fullres_2, p.products_image_sm_3, p.products_image_xl_3, p.products_image_fullres_3, p.products_image_sm_4, p.products_image_xl_4, p.products_image_fullres_4, p.products_image_sm_5, p.products_image_xl_5, p.products_image_fullres_5, p.products_image_sm_6, p.products_image_xl_6, p.products_image_fullres_6, p.oferta, p.novedad, p.`2080`, p.products_tax_class_id, p.products_price AS products_price, p.products_price_old, p.products_price_rsp, p.products_quantity, p.products_model, p.products_date_added, p.products_date_available, p.manufacturers_id, DATE_FORMAT(p.disponibilidad,'%e/%c/%Y') AS disponibilidad_fecha, p.tinta_reffab, p.ref_fabricante, p.tinta_color, p.tinta_pi_cod, p.tinta_relacionados, p.group_id, p.permalink, p.tiendaCT_mostrar, p.tiendaOF_mostrar, p.tiendaOC_mostrar , p.group_id AS group_id_real, '0' AS group_id, m.manufacturers_id, m.manufacturers_name, pd.products_name, pd.products_description, pd.products_description_short, pd.products_url, IF(s.status, s.specials_new_products_price, NULL) AS specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) AS final_price , SUM(tr.tax_rate) AS tax_rate FROM products p LEFT JOIN manufacturers m using(manufacturers_id) LEFT JOIN specials s ON p.products_id = s.products_id LEFT JOIN groups AS g ON p.group_id = g.group_id LEFT JOIN tax_rates tr on p.products_tax_class_id = tr.tax_class_id LEFT JOIN zones_to_geo_zones gz ON tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null OR gz.zone_country_id = '0' OR gz.zone_country_id = '195') AND (gz.zone_id is null OR gz.zone_id = '0' OR gz.zone_id = '161'), products_description pd, categories c, products_to_categories p2c WHERE p.products_status = '1' AND ( IF(g.group_status IS NOT NULL,g.group_status,1) ) AND c.categories_status = '1' AND p.products_id = pd.products_id AND pd.language_id = '3' AND p.products_id = p2c.products_id AND p2c.categories_id = c.categories_id AND p.tiendaCT_mostrar = '1' ) AND (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) <= 1.5) GROUP BY p.products_id, tr.tax_priority ORDER BY CASE WHEN pd.products_name = '' THEN 0 WHEN p.ref_fabricante = '' THEN 0 WHEN pd.products_name LIKE '%' THEN 0 WHEN pd.products_name LIKE '%' THEN 1 WHEN pd.products_name LIKE '%%' THEN 2 ELSE 3 END ASC , products_ordered DESC, pd.products_name LIMIT 100