1、select case when max(adate)>max(bdate) then max(aid) else max(bid) end from (select a.date adate,a.id aid,b.date bdate,b.id bid from test1 a,test3 b where a.id<>b.id)
2、select case when max(adate)>max(bdate) then max(aid) else max(bid) end from (select a.date adate,a.id aid,b.date bdate,b.id bid from test1 a,test3 b where a.id=b.id)