qtydate
----------------------------------------------
132005/01/17
152005/01/19
32005/01/25
1052005/01/27
12005/01/31
3522005/02/03
122005/02/04
2552005/02/07
62005/02/18
12005/02/19
282005/02/21
12005/02/22
3942005/02/23
3592005/02/24
3132005/02/25
3252005/02/26
5442005/02/27
682005/02/28
22005/03/01
求一個SQL寫法,將每個月的數量求和,
如:
qrydate
1372005/01
??2005/02
??2005/03
SQL语句如下:
selectsum(qty),datename(year,date)asyear,datename(month,date)asmonth
fromtable
groupbyyear,month