Task :
Find country to which maximum of customers belong.
Query
SELECT country,
count(*)
FROM customers
GROUP BY country
HAVING count(*) =
(SELECT max(max_sal)
FROM
(SELECT count(*) max_sal
FROM customers
GROUP BY country)) ;
I might be missing something, but it can be as simple as this:
SELECT *
FROM ( SELECT country, COUNT (*) max_sal
FROM customers
GROUP BY country
ORDER BY COUNT (*) DESC)
WHERE ROWNUM <= 1;