select greatest(field1,field2,field3) from table_name
sorry!上面的是最大值。 最小值是 select LEAST(field1,field2,field3) from ...
Syntax LEAST ( expr,...)Purpose LEAST returns the least of the list of exprs. All exprs after the first are implicitly converted to the datatype of the first expr before the comparison. Oracle compares the exprs using nonpadded comparison semantics. If the value returned by this function is character data, its datatype is always VARCHAR2. Example SELECT LEAST(’HARRY’,’HARRIOT’,’HAROLD’) "LEAST" FROM DUAL; LEAST ------ HAROLD
select greatest(field1,field2,field3) from table_name 不行,我试过了,都执行不过去
----------------------------------------
field1 | filed2 | filed3 |
-----------------------------------------
21.4 | 23.8 | 90.0 |
-----------------------------------------
这是某个学生的的学习成绩,我要找出去最差的一门课成绩来。
用access中的iif()可以实现,不知道在oracle中该如何实现!?
WHEN condition.. THEN
...else
end
不过你可以用union 试一试
虽然有点烦,但能实现
不过我相信应该会有好的方法
如果找到了,再给你
最小值是
select LEAST(field1,field2,field3) from ...
LEAST returns the least of the list of exprs. All exprs after the first are implicitly
converted to the datatype of the first expr before the comparison. Oracle compares
the exprs using nonpadded comparison semantics. If the value returned by this
function is character data, its datatype is always VARCHAR2.
Example
SELECT LEAST(’HARRY’,’HARRIOT’,’HAROLD’) "LEAST" FROM DUAL;
LEAST
------
HAROLD
不行,我试过了,都执行不过去