+ -
当前位置:首页 → 问答吧 → 数据查询

数据查询

时间:2011-07-30

来源:互联网

有表A如下,条数会很多。

id emp_id name kind update_time
1 1 test1 1 2011-07-25 08:45:14.921
2 1 test2 1 2011-07-26 08:46:14.921  
3 1 test3 2 2011-07-27 08:47:14.921  
4 2 test4 3 2011-07-28 08:48:14.921  
5 2 test5 3 2011-07-29 08:49:14.921  

想查询得到这样的结果
 emp_id name kind update_time
  1 test1 1 2011-07-25 08:45:14.921
  1 test1 5 2011-07-25 08:45:14.921 ---》两条之间插入 kind 为5 时间为上条记录时间
  1 test2 1 2011-07-26 08:46:14.921  
  1 test2 1 2011-07-26 08:46:14.921 ---》两条之间插入 kind 为5 时间为上条记录时间
  1 test3 2 2011-07-27 08:47:14.921  
  2 test4 3 2011-07-28 08:48:14.921  
  2 test4 5 2011-07-28 08:48:14.921 ---》两条之间插入 kind 为5 时间为上条记录时间
  2 test5 3 2011-07-29 08:49:14.921  

在empid=1的每两条数据多一条  
在empid=2的每两条数据多一条
SQL文该怎么写呢??



作者: huayueouran   发布时间: 2011-07-30

详细说明

在empid=1的每两条数据多一条
  1 test1 1 2011-07-25 08:45:14.921
  1 test1 5 2011-07-25 08:45:14.921 ---》两条之间插入 kind 为5 时间为上条记录时间
这是第2条记录插入?

作者: WWWWA   发布时间: 2011-07-30