如何在字段重复的记录里找出单一的记录?谢谢
表A:
col1,col2,col3
a1, b1, c1
a2, b2, c2
表B:
col1,col4
a1, d1
a1, d2
a2, d3
a2, d4
其中 A.col1=B.col1
我想得到的记录集如下:
A.col1,A.col2,A.col3,B.col4
a1, b1, c1, d1(或d2)
a2, b2, c2, d3(或d4)
SQL语句该怎样写呢?谢谢!!!
select a.col1,a.col2,a.col3,x.col4
from a,(select col1,min(col4) from b group by col1) x
where a.col1=x.col1