是这样一个问题:Tel           register
13322223333 2010-10-3 23:12
13322223333 2010-11-7 23:12
15366667777 2008-3-14 10:50
15366667777 2010-11-8 15:12
15988889999             2010-12-8 13:25查询出来的结果:Tel           register
13322223333 2010-11-7 23:12
15366667777 2010-11-8 15:12
15988889999             2010-12-8 13:25查询出来较新的数据
麻烦各位大神,这个SQL怎么写?PS:HQL能实现吗?又怎么写?

解决方案 »

  1.   

    delete from user where id in (select a.id from user a,user b where a.tel=b.tel)
      

  2.   

    delete from table a
     where date!= (select max(date)
                       from table  b
                      where a.id = b.id                    
                          and a.name = b.name 
                                          .....);
    .....你想多条记录的那个字段相同  就写上
      

  3.   

    delete tb 
    where exists(select 1 from tb t where t.tel=tb.tel and t.register>tb.register)