日期:2014-05-18 浏览次数:20342 次
declare @T table (DW int,DADUI int,PERSON varchar(1)) insert into @T select 1,1,'a' union all select 1,1,'b' union all select 1,2,'c' union all select 1,3,'d' union all select 1,4,'e' union all select 1,4,'f' select * from @T /* DW DADUI PERSON ----------- ----------- ------ 1 1 a 1 1 b 1 2 c 1 3 d 1 4 e 1 4 f */ select * from @T t where PERSON=(select max(PERSON) from @T WHERE DW=T.DW AND DADUI=T.DADUI) ORDER BY DW,DADUI /* DW DADUI PERSON ----------- ----------- ------ 1 1 b 1 2 c 1 3 d 1 4 f */
------解决方案--------------------