如何寻找相邻的数据
原始数据templiu2 
 frameid      groupid   bvci   time 
          1                           1            33      22:32 
          2                           2            34      15:10 
          3                           1            33      22:35 
          4                           3            35      18:09 
          5                           2            34      16:05 
          6                           1            33      23:00 
          7                           3            35      19:00 
          8                           2            34      17:00   
 想要得到的结果表#temp1 
       frameid   groupid   bvci   time      与上条groupid   bvci相同的数据的时间差 
             1                        1               33      22:32                                    0 
             2                        2            34         15:10                                    0 
             3                        1            33         22:35                                 22:35-22:32=   3 
             4                        3            35         18:09                                    0 
             5                        2            34         16:05                                 16:05-15:10=55 
             6                        1            33         23:00                                 23:00-22:35=25 
             7                        3            35         19:00                                 19:00-18:09=51 
             8                        2            34         17:00                                 17:00-16:05=55   
 我是用游标实现的,请问如何用SQL语句来实现呢? 
 自己试着写了一条,结果不对,会得到本条数据与本条数据前所有groupid,bvci相同的数据的时间差 
 select   a.*,(a.time_stamp-b.time_stamp)   as   ctime   into   #temp1   from   templiu2   a,   templiu2   b   where   a.id!=b.id   and   a.fr