精确到天
SELECT DATE_FORMAT(create_time, '%Y-%m-%d') AS time, COUNT(*) AS num
FROM customer
WHERE customer_phone > 17862462917
GROUP BY time
WITH ROLLUP
ORDER BY time;
精确到小时
SELECT DATE_FORMAT(create_time, '%Y-%m-%d %H') AS time, COUNT(*) AS num
FROM customer
WHERE customer_phone > 17862462917
GROUP BY time
WITH ROLLUP
ORDER BY time;
精确到分钟
SELECT DATE_FORMAT(create_time, '%Y-%m-%d %H:%i') AS time, COUNT(*) AS num
FROM customer
WHERE customer_phone > 17862462917
GROUP BY time
WITH ROLLUP
ORDER BY time;
精确到秒
SELECT DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') AS time, COUNT(*) AS num
FROM customer
WHERE customer_phone > 17862462917
GROUP BY time
WITH ROLLUP
ORDER BY time;