Skip to content
Advertisement

SQL MAX(COUNT(*)) GROUP BY Alternatives?

I’ve seen many topics about this and none of them is what I’m looking for.
Say we have this simple table:

I want to retrieve the MAX value after grouping. So I do it as follow:

Is there a better way of doing that? I’ve seen a solution in a book that I’m reading that they do it as follows:

But this won’t work :/ Could be that it works in newer T-SQL servers? Currently I’m using 2008 R2.

Advertisement

Answer

You also need to add an alias name for your sub query. Try like:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement