mysql - Maximum Count of Distinct Values in SQL -
Please forgive me if this is answered but can not use search tool or a basic Google query is.
I am trying to return a value that indicates the maximum number of rows to any specific value in a column in SQL. For example, I like something like
SELECT MAX (COUNT (DISTINCT person_id) my_table from MAX_NUM_PERS_ROW And if the person with most lines in the table 5 If there are rows, then the return value will be 5.
Any and all help is appreciated!
You can do nested aggregation:
to select max (cnt) (select person_id, count (*) from mytable group as cnt person_id By) p; If you really want to make that person You can also do this:
select person_id, count (*) as counted by my_table from person_id (*) desc range 1;
Comments
Post a Comment