开发者

Select most frequent from column in

开发者 https://www.devze.com 2023-01-04 16:50 出处:网络
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

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 开发者_JS百科possible to do?

Thanks in Advance

Dean


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号