select
     if x=1 then 字段ca
     if x= 2 then 字段cb
     if x= 3 then  字段c
from 表
where
     if x= 1 then 条件1
     if x= 2 then 条件2
     if x=3  then 条件3x为参数

解决方案 »

  1.   

    select
    decode(x,1,ca,2,cb,3,c,null) as "新字段"
    from 表
    where
    (x= 1 and 条件1) or
    (x= 2 and 条件2) or
    (x= 3 and 条件3)
      

  2.   

    1、select 部分:
    decode(x, 1, 字段ca, 2, 字段cb, 3, 字段c) 字段
    --------
    有一个限制条件:三个字段的类型必须一致2、where 部分:(举个例子)
    假设条件1为:a>b, 条件2为: c>d,  条件3为: e>f
    a>(decode(x, 1, b, a-1))
    and c>(decode(x, 2, d, d-1))
    and e>(decode(x, 3, f, f-1))
    ----------------
    方法很笨,如果可以写存储过程的话最好写存储过程