根据时间段分组统计
ta(用户等级日志表)
user_id user_level log_datetime
1 2 2013-06-26 10:54:22
1 3 2013-06-26 10:54:35
1 4 2013-06-26 10:54:47
1 5 2013-06-26 10:55:07
......................................
tb(用户银币使用表)
user_id silver_use log_datetime
1 40 2013-06-26 10:54:22
1 60 2013-06-26 10:54:25
1 20 2013-06-26 10:54:35
1 30 2013-06-26 10:54:39
1 80 2013-06-26 10:54:47
1 70 2013-06-26 10:54:51
1 80 2013-06-26 10:55:05
........................................
统计用户在升级过程中各消耗多少银币 如
user_id user_level silver_use
1 2~3 120
1 3~4 110
1 4~5 150
...................................
------解决方案--------------------
with ta(user_id,user_level,log_datetime)as(
select 1,2,'2013-06-26 10:54:22' union
select 1,3,'2013-06-26 10:54:35' union
select 1,4,'2013-06-26 10:54:47' union
select 1,5,'2013-06-26 10:55:07')