Let's say i have a table column with these values: 1, 1, 1, 5, 3, 3, 1. Using SQL I want to count occurrences of each value and then display the most frequent one, e.g the result should be 4 because we have four values of one's?
Asked
Active
Viewed 71 times
1 Answers
0
You can just do a GROUP BY
of that column, order them by counts in descending order and limit the output by 1 because you want the highest count value.
SELECT COLUMN_NAME, COUNT(*) AS COL_FREQUENCY
FROM YOUR_TABLE
GROUP BY COLUMN_NAME
ORDER BY COUNT(*) DESC
LIMIT 1;

Vash
- 1,767
- 2
- 12
- 19