MYSQL count of count?

后端 未结 5 2099
执笔经年
执笔经年 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:06

    Try using following query

    SELECT COUNT(a.page_visits) AS no_of_visitors, a.page_visits AS page_count
    FROM(
    SELECT COUNT(DISTINCT pageid) AS page_visits
    FROM vislog
    GROUP BY visid) AS a
    GROUP BY a.page_visits;
    

    Hope it helps...

提交回复
热议问题