select sum(Total) as Total_inDay, date_format(OrderDate,'%Y-%m-%d') as OrderToDay from orders group by OrderToDay
อันนี้สรุปยอดประจำเดือน
select sum(Total) as Total_inMonth, date_format(OrderDate,'%Y-%m') as OrderToMonth from orders group by OrderToMonth
สุดท้ายยากหน่อยครับ สรุปยอดรายสัปดาห์
select
sum(Total) AS Total_inWeek,
date_format(date_add(OrderDate, interval(1-dayofweek(OrderDate)) day),'%Y-%m-%d') as WeekDayStart,
date_format(date_add(OrderDate, interval(7-dayofweek(OrderDate)) day),'%Y-%m-%d') as WeekDayEnd
from
orders
group by
week(OrderDate)