select a.id, max(b.data) as data--或者 min(b.data) from 表A a join 表B b on a.id = b.id group by a.id
select a.id,data=min(b.data) from ta a,tb b where a.id=b.id group by a.id --or select a.id,data=max(b.data) from ta a,tb b where a.id=b.id group by a.id
select b.* from ta a,tb b where a.id=b.id and not exists(select 1 from tb where id=b.id and data1<b.data1) --or select b.* from ta a,tb b where a.id=b.id and not exists(select 1 from tb where id=b.id and data1>b.data1)
表B的结构可鞥那是
id data1 data2 data2
1 100 101 102
1 200 202 203
2 300 302 303
4 400 102 403得到的结果
1 100 101 102
2 300 302 303
或者
1 200 202 203
2 300 302 303
from 表A a join 表B b on a.id = b.id
group by a.id
from ta a,tb b where a.id=b.id group by a.id
--or
select a.id,data=max(b.data)
from ta a,tb b where a.id=b.id group by a.id
not exists(select 1 from tb where id=b.id and data1<b.data1)
--or
select b.* from ta a,tb b where a.id=b.id and
not exists(select 1 from tb where id=b.id and data1>b.data1)