2013-10-29 28 views
0

我想創建顯示用戶增長的圖表,因此我可以在SQL中按年,月和日計算我的用戶,並總結以前的計數?如何計算我的用戶數,然後將它們相加?

For instance: 
4/1/2013 - 1 
4/2/2013 - 2 
4/4/2013 - 1 
4/9/2013 - 4 

Want the result: 
4/1/2013 - 1 
4/2/2013 - 3 
4/4/2013 - 5 
4/9/2013 - 9 

回答

1
select a.date1,sum(b.id) as Mark 
from tab a cross join tab b 
where b.id <= a.id 
group by a.id,a.date1 
相關問題