我有桌子[访问]。当 order_number 为空时,我需要获取按 user_id 和 visit_duration_seconds 总和分组的行,例如,对于用户 [2875636],我将得到:61+151+33+13。每行应该包括它之前的行的总和。
请在下面的预期结果中参考 RESULT 列
user_id starttime visit_duration_seconds order_number 2875636 2013-01-16 18:03:50 61 2875636 2013-01-16 18:08:18 151 2875636 2013-01-16 18:15:43 33 2875636 2013-01-16 18:16:37 13 2875636 2013-01-16 18:18:01 2011 10177888 2875636 2013-01-16 18:24:35 1172 10177884 2875636 2013-01-16 18:32:03 4731 2875636 2013-01-16 18:33:27 407 2875636 2013-01-16 18:37:29 74 2875636 2013-01-16 18:48:55 80 2875636 2013-01-16 19:05:00 1955 2875636 2013-01-16 19:14:12 326 2875636 2013-01-16 19:23:39 972 2875636 2013-01-16 19:33:05 5440 2875636 2013-01-16 19:35:48 43 2875636 2013-01-16 19:41:10 66 2875636 2013-01-16 19:42:03 100 2875636 2013-01-16 19:42:12 2414 10177940 2875636 2013-01-16 19:49:05 432 10177925 2875636 2013-01-16 19:50:19 183 2875636 2013-01-16 19:52:46 2061 2875636 2013-01-16 19:52:53 400 2875636 2013-01-16 20:00:47 338 2875636 2013-01-16 20:08:58 216 2875636 2013-01-16 20:14:21 58 2875636 2013-01-16 20:14:26 196 2875636 2013-01-16 20:19:14 2189 2875636 2013-01-16 20:21:29 424 2875636 2013-01-16 20:24:42 999 2875636 2013-01-16 21:01:39 1810 2875636 2013-01-16 21:02:54 525 2875636 2013-01-16 21:10:06 27 2875636 2013-01-16 21:12:08 282 2875636 2013-01-16 21:51:02 6 2875636 2013-01-16 22:18:34 173 2875636 2013-01-16 23:02:58 318 2875636 2013-01-16 23:45:37 207 3018868 2013-01-16 16:01:45 18 3018868 2013-01-16 16:16:45 39 3018868 2013-01-16 16:22:55 656 3018868 2013-01-16 16:25:54 1852 3018868 2013-01-16 16:29:23 688 3018868 2013-01-16 16:47:26 2258 10177846 3018868 2013-01-16 16:57:41 572 3018868 2013-01-16 17:06:47 1431 3018868 2013-01-16 17:18:32 29 3018868 2013-01-16 17:21:57 45 3018868 2013-01-16 17:29:23 16 3018868 2013-01-16 17:36:47 490
预期结果
user_id starttime visit_duration_seconds order_number RESULT
2875636 2013-01-16 18:03:50 61 61
2875636 2013-01-16 18:08:18 151 212
2875636 2013-01-16 18:15:43 33 245
2875636 2013-01-16 18:16:37 13 258
2875636 2013-01-16 18:18:01 2011 10177888 0
2875636 2013-01-16 18:24:35 1172 10177884 0
2875636 2013-01-16 18:32:03 4731 4731
2875636 2013-01-16 18:33:27 407 5138
2875636 2013-01-16 18:37:29 74 5212
2875636 2013-01-16 18:48:55 80 ...
2875636 2013-01-16 19:05:00 1955 ...
2875636 2013-01-16 19:14:12 326 ...
2875636 2013-01-16 19:23:39 972
2875636 2013-01-16 19:33:05 5440
2875636 2013-01-16 19:35:48 43
2875636 2013-01-16 19:41:10 66
2875636 2013-01-16 19:42:03 100
2875636 2013-01-16 19:42:12 2414 10177940
2875636 2013-01-16 19:49:05 432 10177925
2875636 2013-01-16 19:50:19 183
2875636 2013-01-16 19:52:46 2061
2875636 2013-01-16 19:52:53 400
2875636 2013-01-16 20:00:47 338
2875636 2013-01-16 20:08:58 216
2875636 2013-01-16 20:14:21 58
2875636 2013-01-16 20:14:26 196
2875636 2013-01-16 20:19:14 2189
2875636 2013-01-16 20:21:29 424
2875636 2013-01-16 20:24:42 999
2875636 2013-01-16 21:01:39 1810
2875636 2013-01-16 21:02:54 525
2875636 2013-01-16 21:10:06 27
2875636 2013-01-16 21:12:08 282
2875636 2013-01-16 21:51:02 6
2875636 2013-01-16 22:18:34 173
2875636 2013-01-16 23:02:58 318
2875636 2013-01-16 23:45:37 207
3018868 2013-01-16 16:01:45 18
3018868 2013-01-16 16:16:45 39
3018868 2013-01-16 16:22:55 656
3018868 2013-01-16 16:25:54 1852
3018868 2013-01-16 16:29:23 688
3018868 2013-01-16 16:47:26 2258 10177846
3018868 2013-01-16 16:57:41 572
3018868 2013-01-16 17:06:47 1431
3018868 2013-01-16 17:18:32 29
3018868 2013-01-16 17:21:57 45
3018868 2013-01-16 17:29:23 16
3018868 2013-01-16 17:36:47 490