select ... from a,b where b.bid=a.bid and b.rowid = (select max(rowid) from b bb where bb.bid = b.bid) union all select .... from a,b where a.bid = b.bid(+) and b.bid is null;
select ... from a, (select * from b where b.rowid in (select min(rowid) from b group by id)) b_se where a.id = b_se.id(+)
参考大家的答案,我自己搞定了,select a.id,b2.bid,... from a,(select id,bid,.. from b b1 where b.bid=(select min(bid) from b where id=b1.id)) b2 where b2.id(+)=a.id谢谢大家
如果你需要 b 中的其他字段值的话这样还不行select ... from a,b
where b.bid=a.bid and b.rowid =
(select max(rowid) from b bb where bb.bid = b.bid);
where a.id=s.id
select ... from a,(select id,a1,a2,...,an,max(bid) b_id from b group by id,a1,a2,...,an) s
where a.id=s.id
select ... from a,(select id,max(bid) b_id,max(f1),max(f2),...,max(fn) from b group by id) s
where a.id=s.id
where b.bid=a.bid;
from a,b
where a.id = b.id
and b.bid = (select min(b_se.bid) from b b_se where b_se.id = b.id)
select ... from a,b
where b.bid=a.bid and b.rowid =
(select max(rowid) from b bb where bb.bid = b.bid)
union all
select .... from a,b where a.bid = b.bid(+) and b.bid is null;
from a,
(select * from b where b.rowid in (select min(rowid) from b group by id)) b_se
where a.id = b_se.id(+)
where b.bid=(select min(bid) from b where id=b1.id)) b2
where b2.id(+)=a.id谢谢大家
应该把bid 都换成 id 吧 :)
you are right