sql select most frequent value in group 1

sql select most frequent value in group

SELECT col, COUNT(col) AS value_occurrence
FROM m_table GROUP BY col ORDER BY value_occurrence DESC;

Here is what the above code is Doing:
1. We’re selecting the column we want to count the values for, and the count of those values.
2. We’re grouping the values by the column we’re counting.
3. We’re ordering the values by the count of those values.

Similar Posts