Count maximum times record appears in Database table

后端 未结 2 410
你的背包
你的背包 2021-01-23 15:12

I am unable to find the proper mysql function but am trying to find the maximum number of a times a single record appears within a database relative to all other records.

<
相关标签:
2条回答
  • 2021-01-23 15:19

    Can't nest directly, otherwise you'll get a grouped max. Nest the selects instead.

    select max(c) from (
      select
        count(*) c
      group by
        .. whatever ...
      ) x
    
    0 讨论(0)
  • 2021-01-23 15:42
    SELECT MAX(MAX_COUNT) FROM (SELECT COUNT(COLUMN_NAME) AS MAX_COUNT FROM TABLE_NAME GROUP BY COLUMN_NAME)
    
    0 讨论(0)
提交回复
热议问题