[code=SQL] select id,col1,col2 from t order by greatest(col1,col2); --最小用 least [code]
select id,col1,col2 from t order by greatest(col1,col2); --最小用 least
with t(id,col1,col2) as( select 1,3,4 from dual union all select 2,55,66 from dual union all select 3,67,33 from dual union all select 4,1,77 from dual union all select 5,2,76 from dual ) select * from t order by (case when col2>col1 then col2 else col1 end);
select * from table order by (case when col2>col1 then col2 else col1 end); 试下这个。。
oracle里面 函数挺多的 要靠自己挖掘了 很多功能强大但是用到的比较少
with t(id,col1,col2) as( select 1,3,4 from dual union all select 2,55,66 from dual union all select 3,67,33 from dual union all select 4,1,77 from dual union all select 5,2,76 from dual ) select * from t order by (case when col2>col1 then col2 else col1 end);
select id,col1,col2
from t
order by greatest(col1,col2);
--最小用 least
[code]
select id,col1,col2
from t
order by greatest(col1,col2);
--最小用 least
with t(id,col1,col2) as(
select 1,3,4 from dual
union all select 2,55,66 from dual
union all select 3,67,33 from dual
union all select 4,1,77 from dual
union all select 5,2,76 from dual
)
select * from t order by (case when col2>col1 then col2 else col1 end);
试下这个。。
select 1,3,4 from dual
union all select 2,55,66 from dual
union all select 3,67,33 from dual
union all select 4,1,77 from dual
union all select 5,2,76 from dual
)
select * from t order by (case when col2>col1 then col2 else col1 end);