select year(datetime) as year,month(datetime) as month,name into #t1 from table1
select count(name) as times,month,year from #t1 group by year,month
select count(name) as times,month,year from #t1 group by year,month
select datepart(year,使用时间) as 'year',datepart(month,使用时间) as 'month',count(ID) as 'count'
from your_table
group by datepart(year,使用时间),datepart(month,使用时间)
from tablename
group by to_char(使用时间,'yyyymm')
-in oracle-