风言枫语  

month   salesPerMonth

1 2
2 3
3 2
4 4
5 3
6 3
   

 

写条SQL语句把上表转成下表:

month   总销量

1             2
2             5
3             7
4             11
5             14
6             17

 

答案:

selects2.[month],Sum(s1.salesPerMonth)as'总销量'

 FromSaless1,Saless2

 where s1.[month]<=s2.[month]

 Groupbys2.[month]

 

posted on 2013-10-12 22:14  风言枫语  阅读(245)  评论(0编辑  收藏  举报