某公司面试的SQL题目

数据表test如图:要求统计截止到某月的总额。。。

sql:

方法1:

select t2.month,Sum(t1.amount) from test t1 inner join test t2 on t1.month<=t2.month group by t2.month

方法2:

select t1.month,(select sum(t2.amount) from test t2 where t2.month<=t1.month) from test t1
posted @ 2013-03-04 17:34  qanholas  阅读(440)  评论(0编辑  收藏  举报