I have next table:
x
id value
1 2
2 4
3 2
4 2
5 3
How I can get most common (common means that the count of 2 is 3, count of 4 is 1 and count of 3 is 1, so common is 2) ‘value’? in this case it is ‘2’?
Advertisement
Answer
you can use group by
select value
from the_table
group by value
order by count(*) desc
limit 1