日期:2014-05-17 浏览次数:20817 次
SQL: select tt.sid, max(tt.anum) as anum, max(tt.bnum) as bnum from ( select a.aid as sid, a.anum, null as bnum from A union select b.bid as sid, null as anum, b.bnum from B )tt group by tt.sid; RESULT: SID ANUM BNUM ---------- ---------- ---------- 1 10 10 2 10 10 3 10 4 10