我有一个事件记录数据库,我需要找到每个客户的所有事件,并从每个客户的最后一条记录到第一个记录以一周的间隔对它们进行分组。
FirstEvent LastEvent Client
==
2011-01-01 06:55:21.000 |2011-04-30 21:46:09.000 |Client1
2011-01-01 06:20:00.000 |2011-02-23 12:43:55.000 |Client2
2011-01-03 08:34:33.000 |2011-04-30 09:00:39.000 |Client3
2011-01-01 02:14:45.000 |2011-04-30 15:31:41.000 |Client4
2011-01-01 08:08:12.000 |2011-02-21 09:41:28.000 |Client5
2011-02-01 11:29:28.000 |2011-04-29 09:13:25.000 |Client6
现在我必须计算每个客户的记录并像这样对它们进行分组
Client From To Records
==
Client1 |2011-04-30 21:46:09.000 |2011-04-23 21:46:09.000 |200
Client1 |2011-04-16 21:46:09.000 |2011-04-09 21:46:09.000 |400
...Until the the first date
Client1 |2011-01-08 06:55:21.000 |2011-01-01 06:55:21.000 |250
Client2 |2011-02-23 12:43:55.000 |2011-02-16 12:43:55.000 |50
...The same for each user
我希望有人可以帮助我找到一种方法来输出这个。