K3

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
select *  from 
(
    
--获取冗余数据中的唯一最小行数据
    select *  from table_1 t1
     
where t1.id in 
    (
        
select min(t2.id) from table_1 t2 
        
group by t2.employeeid having t1.employeeid=t2.employeeid and count(*> 1
    )
    
union all
    
--获取非冗余数据
    select * from table_1 t4 where t4.id in
    (
        
select min(t3.id) from table_1 t3
        
group by t3.employeeid having t4.employeeid = t3.employeeid and count(*= 1
    )
) t5 
order by id
posted on 2007-03-07 11:40  K3  阅读(261)  评论(0编辑  收藏  举报