Skip to content
Advertisement

MAX COUNT BY GROUP BY Retrieve only max count records

I want to return only the max count record from the following grouping.

This Returns:

Ideally it should return only :

Sort the manufname asc by

Tried this but returns the same:

Advertisement

Answer

You can use dense_rank or rank window function. Also I have removed unnecessary aggregation in the top query.

You can use TOP with ties as following

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