Stat number of records from a month in MySQL code example

Suppose you have a table that records visitor information of the visitors of your website. The information of a visitor includes it's IP address, request URI, referee, user agent, etc. The data is stored in a MySQL database table. Here is the table definition:

Field Type Null Key Default Extra
ID int(11)NO PRI NULLauto_increment
IP varchar(1000)NO
UserAgent textNO NULL
RequestTime datetimeYES NULL
InsertDate datetimeYES NULL
RequestUri textNO MUL NULL
cookie textNO NULL
refer textNO NULL

Here is SQL code example to get total number of all visitors comes from Google SERPs in a particular month.

SELECT COUNT(*) FROM stat WHERE refer LIKE '%google%' AND MONTH(insertdate)='1' AND YEAR(insertdate)='2022' AND DAY(insertdate)='17';