Posts

Showing posts with the label Weekly inserted records

How to fetch the no: of weekly inserted records in MySQL

Image
SELECT   COUNT(*) AS reports_in_week,   DATE_ADD(created_at, INTERVAL(1-DAYOFWEEK(created_at)) DAY) as start_day,   DATE_ADD(created_at, INTERVAL(7-DAYOFWEEK(created_at)) DAY) as end_day FROM   your_table_name GROUP BY   YEAR(created_at) + .01 * WEEK(created_at) The desired output will be.