SQL数据库中日期时间类型,按日期group by 实现

 

每天学习一点点 编程PDF电子书免费下载: http://www.shitanlife.com/code

 

cast(starttime as date):  时间转日期类型

 

实例SQL:


SELECT
COUNT (ID) AS pvNum,
COUNT (DISTINCT userid) AS userNum,
cast(starttime as date) AS staDay
FROM
t_e_visit_record
WHERE true
AND starttime >= '2018-03-20'
GROUP BY
cast(starttime as date)

posted @ 2018-04-03 10:38  漫步CODE人生  阅读(13495)  评论(0编辑  收藏  举报