To : dawugui(潇洒老乌龟)
那如果表中是下面这个情况呢??
A B C
1 1 2006-1-1
1 1 2006-1-1
1 2 2006-1-1
2 1 2006-1-1
3 3 2006-1-2
3 3 2006-1-2
3 4 2006-1-2
4 3 2006-1-2
select id1=identity(int,1,1),* into t1 from tb
select m.a,m.b,m.c from t1 m,
(select c,min(id1) as id1 from t1 group by c) n
where m.id1 = n.id1 and m.c = n.c
A B C
1 1 2006-1-1
2 2 2006-1-1
3 3 2006-1-2
4 4 2006-1-2
select m.* from tb,
(select c,min(a) as a from tb group by c) n
where m.c = n.c and m.a = n.a