Commencez par obtenir les sommes pour chacun individuellement :
# Sum of lakes
SELECT code, count(*) AS sum FROM lakes GROUP BY code
# Sum of mountains
SELECT code, count(*) AS sum FROM mountains GROUP BY code
Regroupez ensuite les résultats et sélectionnez toutes les lignes où la somme des montagnes d'un pays est inférieure au nombre de lacs :
SELECT l.code AS code, l.sum AS lake_count, m.sum AS mountain_count
FROM
(SELECT code, count(*) AS sum FROM lakes GROUP BY code) AS l JOIN
(SELECT code, count(*) AS sum FROM mountains GROUP BY code) AS m
ON l.code = m.code
WHERE m.sum < l.sum