时间:2021-07-01 10:21:17 帮助过:3人阅读
也不是说换行,数据库里是那样的结构,
意思就是只要你输入sql语句,执行
的结果就是我说的那样。全部列出来
被你弄糊涂了
select DATE_FORMAT(date, '%Y-%m') as date, count(*) as num from tbl_name group by 1不行吗?
select DATE_FORMAT(date, '%Y-%m') as date, count(*) as num from (select 2 as num, '2013-07-24' as date union select 5,'2013-07-25' union select 8, '2013-08-03' union select 10, '2013-08-22' union select 4, '2013-09-10') tgroup by 1得到
被你弄糊涂了
我改改去,好像有点启发了
被你弄糊涂了
我改改去,好像有点启发了
select DATE_FORMAT(date, '%Y-%m') as date, count(*) as num from tbl_name group by 1
这个是有几条记录 没有计算每个月的和。貌似不对。我再研究看看