情況2:表中存在部分數據重復的字段,即 重復數據中至少有一個字段不重復create table #
(用戶ID int, 姓名 varchar(10), 年齡 int, 日期 DateTime )
insert into #
select 111, '張三', 26 2010-02-23 union all
select 222, '李四', 25 2010-03-13 union all
select 333, '王五', 30 2011-03-25 union all
select 111, '張三', 26 2011-07-07方法:--當兩條重,取日期大的一條select * from t awhere not exists (select 1 from t where a.用戶ID=用戶ID a.姓名=姓名 and 日期>a.日期)