SELECT
DATE_FORMAT(created_time, '%Y-%m-%d') created_day,
COUNT(1) orders
FROM
p_order
GROUP BY
created_day
ORDER BY created_day DESC;
DATE_FORMAT:數(shù)據(jù)庫自帶函數(shù)
%Y-%m-%d %H:按時查詢
%Y-%m-%d:按天查詢
%Y-%m:按月查詢
SELECT
DATE_FORMAT(created_time, '%Y-%m-%d') created_day,
COUNT(1) orders
FROM
p_order
GROUP BY
created_day
ORDER BY created_day DESC;
DATE_FORMAT:數(shù)據(jù)庫自帶函數(shù)
%Y-%m-%d %H:按時查詢
%Y-%m-%d:按天查詢
%Y-%m:按月查詢