请教按时间分组查询

MySql 码拜 8年前 (2016-02-17) 1038次浏览
本人想查询每天tongji表里字段op=1的数量统计,而且结果要按天输出
求高手指点
解决方案

13

select date,count(0) from tongji where op=1 group by date;

13

select date,count(case when op=1 then 1 end) as cn from tongji  group by date;

14

select CreateDate,count(*) from t_housebookin group by CreateDate
查询结果
CreateDate (无列名)
2012-07-11 00:00:00.000 54
2013-10-23 09:31:44.000 1
2008-03-05 00:00:00.000 51
2000-03-10 00:00:00.000 1
1988-07-26 00:00:00.000 1
2011-10-24 00:00:00.000 52

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明请教按时间分组查询
喜欢 (0)
[1034331897@qq.com]
分享 (0)