There was a need to extract from the database the value that was repeated more times.
I tried different options, but I’m doing something wrong.
Example:
Column with numbers 8 1 2 6 8 5 1 8
- you need to display the number 8.
There was a need to extract from the database the value that was repeated more times.
I tried different options, but I’m doing something wrong.
Example:
Column with numbers 8 1 2 6 8 5 1 8
- you need to display the number 8.
In this case, they usually resort to counting the number of values using the COUNT()
function and then sorting using ORDER BY
SELECT number FROM tbl GROUP BY number ORDER BY COUNT(*) DESC LIMIT 1
Source: https://ru.stackoverflow.com/questions/544343/
All Articles