SELECT MAX(val) val FROM (SELECT MAX(LEAST(a.cena_ddv, a.cena_ddv_pop)) val FROM artikli a WHERE a.aktivnost='Y' AND a.kat_id IN (SELECT kat_id FROM kategorije WHERE permalink='uhani') UNION SELECT MAX(LEAST(ap.cena, ap.cena_akcija)) val FROM artikli_podrobnosti ap, artikli a WHERE ap.aktivnost='YES' AND a.art_id = ap.artikel_id AND a.kat_id IN (SELECT kat_id FROM kategorije WHERE permalink='uhani')) a