日期:2014-05-18 浏览次数:20664 次
--> 测试数据:[tbl]
if object_id('[tbl]') is not null drop table [tbl]
create table [tbl]([a] int,[b] int,[c] int,[d] int)
insert [tbl]
select 1,1,1,1 union all
select 1,1,1,2 union all
select 2,2,2,2 union all
select 2,2,2,3 union all
select 3,3,3,3 union all
select 4,4,4,4
select a,b,c,d from(select *,row_number()over(partition by a,b,c
order by getdate()) as id from tbl)a where id=1
/*
a b c d
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
*/