I want to make a query that in theory (and wrong for practical purposes) would be something like this
select A,MAX(COUNT(B)) from Tabla group by A;
However I know this doesn't work. For MAX(count(op)) to work, you would have to put it alone, that is, it would be something like this:
select MAX(COUNT(OP)) from Tabla group by A;
However, I require the A attribute associated with MAX(...).
How could I do it? Doing something analogous to the first thing, I get the following error:
ORA-00937: not a single-group group function
As the error tells you, you have two nested group functions.
You don't need to do two nested queries, you can group by counting:
and the result you order:
and you keep only the first:
An alternative to Paul's proposal could be:
It is a bit more complex, but it has two interesting points:
A
with the same maximum, this query will return all of them.