Suppose now I have a table T which is like this:
A|B
1|1
1|2
2|1
2|2
2|3
3|1
3|2
3|3
With select A, count(*) from T group by A we should get:
A|count(*)
1|2
2|3
3|3
Now I need to get the last two rows in the previous query — which have the maximum value of count(*). How can I do this in a single query?
Thanks.
1 Answer