Skip to content
Advertisement

How to select the highest number of occurances for a certain text value?

Im trying to find the person who has drank most beer types from USA. The result should be just be the name of that person alone and not include a count column. How should I perform the select statement? The result should look like this:

The table above should be acquired from the table below:

Appriciate the help

Advertisement

Answer

Use GROUP BY, ORDER BY and LIMIT if you want one result (even when there are ties):

If you want all rows when there are ties, then use window functions:

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