MYSQL count of count?

后端 未结 5 2114
执笔经年
执笔经年 2020-12-10 19:36

I have a mysql table like:

id, visitorid, pageid

When a visitor hits the website it stores their visitor id and the page id as a row.

5条回答
  •  死守一世寂寞
    2020-12-10 20:04

    I could solve it this way:

    SELECT cnt, COUNT(cnt) FROM (
        SELECT COUNT(visid) as cnt FROM vislog GROUP BY visid
    ) x GROUP BY cnt ORDER BY cnt ASC
    

    The little x is important.

提交回复
热议问题