我的一条记录中的3个字段中的数据比较后,我要用到其中最小的一个值,不知道如何实现?
   人家说这个没法实现,我不信,人家sqlserver\access都能(用iif和case)实现,为什么oracle就不行!

解决方案 »

  1.   

    比如:
    ----------------------------------------
    field1  |   filed2  |   filed3          |
    -----------------------------------------
    21.4    |  23.8     |  90.0             |
    -----------------------------------------
    这是某个学生的的学习成绩,我要找出去最差的一门课成绩来。
    用access中的iif()可以实现,不知道在oracle中该如何实现!?
      

  2.   

    CASE WHEN condition.. THEN
         WHEN condition.. THEN
                        ...else
                        end
      

  3.   

    我也没有想到好方法
    不过你可以用union 试一试
    虽然有点烦,但能实现
    不过我相信应该会有好的方法
    如果找到了,再给你
      

  4.   

    select greatest(field1,field2,field3) from table_name
      

  5.   

    sorry!上面的是最大值。
    最小值是
    select  LEAST(field1,field2,field3) from ...
      

  6.   

    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
      

  7.   

    select greatest(field1,field2,field3) from table_name
    不行,我试过了,都执行不过去