Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select most frequent from column in

Hi
i have a columm in the table and i want to select the most common item from the selected column. The table is set up publication:

  • id
  • Title
  • published

I want to beable to select the most recurring places where publications have been published. Is this possible to do?
Thanks in Advance
Dean

like image 893
Dean Avatar asked Jan 23 '26 03:01

Dean


1 Answers

select published, count(*) nbr
from table1
group by published
order by nbr desc
limit 1

You don't really need the count, but if you wanted confirmation that the choice seemed reasonable, you could use it. Also, you didn't specifically say whether you wanted ONLY the one, or wanted to see which was the most frequent, along with frequencies of the other records. Take off the limit 1 if you want to see all records.

like image 162
MJB Avatar answered Jan 25 '26 19:01

MJB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!