generate a weekly report in mysql

You can try this option –

select t.d,cnt from
(
select 'Saturday' as d union all
select 'Sunday' union all
select 'Monday' union all
select 'Tuesday' union all
select 'Wednesday' union all
select 'Thursday' union all
select 'Friday'
)t left join
(
SELECT DAYNAME(created_at) AS DAY,  count(*) as cnt 
FROM `eco_orders` 
WHERE created_at >= DATE(NOW()) - INTERVAL 7 DAY 
GROUP BY DAY
)t1 on t.d=t1.day

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top