用select语句。查询出最近(比如最近一周)的信息,每个工号一个就行了,其余的都删除不要。工号    创建时间               工作内容
1       2009-07-14              工工工工2       2009-07-14             工工工工3       2009-07-5             工工工工1       2009-07-13              工工工工2       2009-07-7              工工工工3       2009-07-4              工工工工
 
如何出现下表:工号    创建时间               工作内容
1       2009-07-15              工工工工2       2009-07-14             工工工工3       2009-07-5             工工工工

解决方案 »

  1.   

    select * from 表 t where not exists(select 1 from 表 where 工号=t.工号 and 创建日期<t.创建日期)
      

  2.   

    用 distinct 关键字实现了。
    select distinct 工号,创建时间,内容 from 表
      

  3.   

    select * from 表 t where 
    创建时间 =(select min(创建时间) from 表 where 工号=t.工号 )
      

  4.   

    select distinct(工号),创建时间,内容  from 表名
      

  5.   

    select * from 表 t where 
    创建时间 =(select min(创建时间) from 表 where 工号=t.工号 
      

  6.   


    select * from tb a where 创建时间 = (select max(创建时间) from tb  where 工号 = a.工号group by 工号)
      

  7.   


    select 工号,max(创建时间),工作内容  from 表 group by 工号,工作内容
      

  8.   

    select min(工号),创建时间,工作内容 
    from tb
    group by 创建时间,工作内容