Mysql: calculate frequency of visits

I have this table

CREATE OR REPLACE TABLE hits (ip bigint, page VARCHAR(256), agent VARCHAR(1000), 
                              date datetime)

and I want to calculate the frequency of googlebot visits for each page.

... WHERE agent like '%Googlebot%' group by page
+3
source share
2 answers

Using:

  SELECT page,
         COUNT(*)
    FROM hits
   WHERE agent LIKE '%Googlebot%'
GROUP BY page
+4
source

Try the following:

select page, count(1) as visits
  from hits
 where agent like '%Googlebot%'
 group by page;
+1
source

Source: https://habr.com/ru/post/1765441/


All Articles