SELECT a.id, a.name, a.alias, a.category_id, a.category_id_wrapper,
a.image, a.price, a.price_old, a.hits, a.ordering,
COALESCE(NULLIF(TRIM(a.repair), ''), b.repair) as repair,
COALESCE(NULLIF(TRIM(a.guarantee), ''), b.warrant) as guarantee,
MIN(b.price) as min_price, MIN(b.price_h) as min_price_h
FROM fs_service AS a
INNER JOIN fs_service_sub AS b
ON a.published = 1
AND b.service_id = a.id
AND b.price > 0 AND b.price_h > 0
WHERE a.published = 1
AND b.published = 1
AND b.price > 0
AND (a.category_id_wrapper LIKE '%,4299,%'
OR a.cat_sub LIKE '%,4299,%')
GROUP BY a.id
ORDER BY a.hits DESC, a.ordering DESC, a.id DESC