Stubla
SELECT nazpredmet, COUNT(jmbag) as broj
FROM upisanpredmet, predmet
WHERE upisanpredmet.sifpredmet = predmet.sifpredmet AND
ocjena > 1 AND ocjena is not null
GROUP BY nazpredmet, upisanpredmet.sifpredmet
HAVING COUNT(jmbag) > (SELECT COUNT(jmbag)
FROM upisanpredmet p2
WHERE p2.sifpredmet = upisanpredmet.sifpredmet
AND ocjena = 1 AND ocjena is not null)
ORDER BY broj DESC, nazpredmet