To aggregate data by month/week, first find the beginning date of the month/week of the date and GROUP by that beginning date. If the DATE_TRUNC() function can be used to get the head date, such as Google BigQuery, you can aggregate the data as follows. SELECT DATE_TRUNC(dt, MONTH) AS dt_month ,SUM…