求 每个月输入数据总和
name date
a 2007-1-1
b 2007-1-2
c 2007-1-20
d 2007-2-20
e 2007-3-5
f 2007-4-7
g 2007-4-7
--------------------
求结果
日期 总数
2007-1 3
2007-2 1
2007-3 1
2007-4 2
------解决方案--------------------Select
Convert(Varchar(7), [date], 120) As 日期,
Count(*) As 总数
From
TableName
Group By
Convert(Varchar(7), [date], 120)
Order By
日期
------解决方案--------------------select date as 日期 ,count(*) as 总数
from tb
group by date