从数据库查最近七天每天的数据总量

SELECT DATE_FORMAT( 字段名e, '%y-%m-%d' ) days,count(*) count
FROM( SELECT * FROM 表名 WHERE DATE_SUB( CURDATE( ), INTERVAL 7 DAY ) <= date( 字段名) ) as time
GROUP BY days;

猜你喜欢

转载自www.cnblogs.com/hanp/p/10489801.html