0

am having a database with above data and i want to select only country with highest registrars

here is my query

SELECT COUNTRY FROM USERS HAVING COUNTRY = MAX(COUNTRY)

TABLE USERS

ID NAME COUNTRY

1  JOHN  USA
2  JOHN  CA
3  JOHN  USA
4  JOHN  UK
5  JOHN  USA
jeff tio
  • 5
  • 2
  • 1
    Possible duplicate of [How can I SELECT rows with MAX(Column value), DISTINCT by another column in SQL?](https://stackoverflow.com/questions/612231/how-can-i-select-rows-with-maxcolumn-value-distinct-by-another-column-in-sql) – Alejandro Blasco May 21 '19 at 09:08

1 Answers1

1

Maybe this is what you need:

EDIT: Just remove COUNT(*) As Total

SELECT COUNTRY
FROM USERS 
GROUP BY COUNTRY
ORDER BY COUNT(*) DESC
LIMIT 1;
FanoFN
  • 6,815
  • 2
  • 13
  • 33