select sum(列名) from 表
where Date between '2012-1-1' and '2012-3-31' group by month(Date )
找一个根据时间得到月份的函数,根据月份分组,Month(date)就是得到月份的。
楼上的办法不错。
select sum(qty), datename(year, date) as year, datename(month, date) as month from table group by year, month --------------------------------- qry date 137 2013-01 99 2013-02