How can I count visitors per page per day using MySQL?

MySQLMySQLi Database

Note: We assume we have created a database named ‘DBNAME’ and a table named ‘tableName’.

Let us understand how the count of visitors per day per page can be queried using MySQL. This can be done using the bit group function −

Query

SELECT DATE(date) Date, page_id, COUNT(*) colName
FROM tableName
GROUP BY DATE(date), page_id

Here ‘colName’ refers to the ‘visits per day’ column, and ‘tableName’ refers to the table that contains details about visitors.

It makes sure that the duplicate values in the table are removed when the above query is run.

raja
Published on 09-Mar-2021 13:25:42
Advertisements