mysql查询近七天订单的状态(已签收【1代表已签收】,未签收【5代表未签收】)的数量,按照日期和签收状态划分。表中的订单创建的日期(createTime)是带时分秒的日期时间格式的
select fullName,addedTime from t_user where date_sub(CURDATE(),INTERVAL 7 DAY) <= DATE(addedTime) 自己替换一下字段在加上是否签收的条件
select 字段,case 字段1 when 1 then '已签收' when 2 then '未签收' end 签收状态 from table where datediff(now(),createTime)<=7
group by 字段,字段1
select 字段,case 字段1 when 1 then '已签收' when 2 then '未签收' end 签收状态 from table where date_sub(curdate(),interval 7 days)<=date(时间字段);
希望可以帮到你