面试之BI-SQL--table转换[2]
month salesPerMonth
122332445363
写条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]