SELECT u.hour,
COUNT(*)
FROM (SELECT 获取create_time的小时部分 AS hour
FROM user
WHERE 获取create_time的日期部分 = 某个日期) u
GROUP BY u.hour
具体的mysql日期函数可以查一下API。
select hour(create_time) AS saleHour, count(id) AS saleCountfrom tableName where date_format(create_time, ‘%Y-%m-%d’ ) = ‘2021-09-07’
group by hour(create_time)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)