里上图 表 aaa, 要按月份查找,a 出现的次数,代码如下
SELECTCAST(YEAR(rq) as varchar) + '-' + CAST(MONTH(rq) as varchar) AS date,
count(*) AS '次数'
FROM aaa
where a="a"
GROUP BY
CAST(YEAR(rq) as varchar) + '-' + CAST(MONTH(rq) as varchar)
结果如下图,看看是不是你要的
select DATE_FORMAT(来电时间,'%Y-%m') as 月, 问题类别 , count(1) as 数量 from( select 来电时间, 问题类别 from mytable where 问题类别 = '农村用水投诉' ) tmptable
group by DATE_FORMAT(来电时间,'%Y-%m') ,问题类别 ORDER BY 月 ASC
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)