日期:2014-05-17 浏览次数:20605 次
SELECT [name],[sex],[age],[love],[marry]
FROM
(
SELECT *,rn=ROW_NUMBER() OVER(PARTITION BY [name],[sex] ORDER BY GETDATE())
FROM [People]
) T
WHERE rn=1
create table People
(name varchar(10), sex varchar(10), age int, love varchar(10), marry varchar(10))
insert into People
select '张三', 'N', 22, '足球', '否' union all
select '张三', 'F', 50, '篮球', '否' union all
select '张三', 'N', 50, '篮球', '否' union all
select '赵六', 'F', 30, '上网', '是' union all
select '赵六'