2013年7月4日 星期四

{SQL} Group by 年月

Group by 年 與 月:
SELECT ItemId,SUM(QTY),year(Date) as year, month(Date) as month
  FROM abcTable
  where ItemId='8687'
  group by ItemId,year(Date) ,month(Date)
  order by year desc


參考資訊:
http://www.wretch.cc/blog/five/9184368