mysql 统计sql

-- 今日
  select * from order_info where  TO_DAYS(NOW()) = TO_DAYS(create_time) 

-- 昨天
select * from order_info where TO_DAYS(NOW()) - TO_DAYS(create_time) = 1

-- 本周
 select * from order_info where  YEARWEEK(NOW()) = YEARWEEK(create_time);

-- 本月

  select * from order_info where  DATE_FORMAT(NOW(),'%Y-%m') = DATE_FORMAT(create_time,'%Y-%m')

-- 本年
select * from order_info where DATE_FORMAT(NOW(),'%Y') = DATE_FORMAT(create_time,'%Y')

你可能感兴趣的:(mysql 统计sql)