A B C
1 1 1
1 2 2
2 1 3
2 2 4
distinct A以后,B和C的值你如何关联?
逻辑上讲不同的,除非如下
A B C
1 1 1
1 1 1
2 2 2
2 2 2
那么distinct a,b,c
可以留下两条纪录
1 1 1
1 2 2
2 1 3
2 2 4
distinct A以后,B和C的值你如何关联?
逻辑上讲不同的,除非如下
A B C
1 1 1
1 1 1
2 2 2
2 2 2
那么distinct a,b,c
可以留下两条纪录
2 union all select 1,1,1 from dual
3 union all select 2,1,3 from dual
4 union all select 2,2,4 from dual;4 rows insertedSQL> select * from test; A B C
---------- ---------- ----------
1 1 1
1 1 1
2 1 3
2 2 4SQL> select a,max(b) b,max(c) c from test
2 group by a; A B C
---------- ---------- ----------
1 1 1
2 2 4SQL>
SQL> select a,b,c from (select a,b,c,row_number() over(partition by a order by a) rd from test) where rd=1; A B C
---------- ---------- ----------
1 1 1
2 1 3