按天、小时、分、秒统计 日期范围

按天:%Y-%m-%d 

select DATE_FORMAT(create_time,'%Y-%m-%d') tm, count(*) from t_xx  where group by tm

select count(*) from t_xx where  create_time > "2023-04-01" and create_time < "2023-04-02"

按秒:%Y-%m-%d %H:%i:%s

select DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') tm, count(*) from t_xx  where group by tm

你可能感兴趣的:(sql)