日期:2014-05-17 浏览次数:20730 次
with t as ( select 1 id,'a' r1,'b' r2 from dual union all select 2 id,'b' r1,'a' r2 from dual union all select 3 id,'c' r1,'d' r2 from dual union all select 4 id,'d' r1,'c' r2 from dual ) select t.id,t.r1,t.r2 FROM t
with t as ( select 1 id,'a' r1,'b' r2 from dual union all select 2 id,'b' r1,'a' r2 from dual union all select 3 id,'c' r1,'d' r2 from dual union all select 4 id,'d' r1,'c' r2 from dual ) select max(id), r1, r2 from (select id, greatest(r1,r2) r1, least(r1,r2) r2 FROM t) group by r1,r2;