Skip to content
Advertisement

Return the highest count record

The data I am working on looks like below-

I want to be able to extract the B_id that has the highest count for a given A_id

The result should look like-

How to achieve this result?

Advertisement

Answer

One option is to filter with a subquery:

You can also use window functions:

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