SELECT DAY(temp.last14day), ifnull(sum(orders.price), 0) as 'total'
FROM (
select curdate() - INTERVAL (last14.num14) DAY as last14day from ( select 0 as num14
union all select 1 union all select 2 union all select 3 union all select 4 union all select 5
union all select 6 union all select 7 union all select 8 union all select 9 union all select 10
union all select 11 union all select 12 union all select 13 union all select 14 ) as last14
) as temp
left join orders on date_format(orders.created_at, '%Y-%m-%d') = temp.last14day group by temp.last14day order by temp.last14day desc limit 15;
网友评论