本帖最后由 New_sara 于 2012-11-20 10:50:53 编辑
select
case when &value >=1 then 1 else 0 end as a,
case when &value >=2 then a + 2 else 0 end as b,
case when &value >=3 then b + 3 else 0 end as c
from dual
如上中,我想在第二个case when 里面用到 a 的值。
各位高手。。不要观望阿。。回帖告诉我吧。。。急。
------最佳解决方案--------------------
这样?
select
case when &value >=1 then 1 else 0 end as a,
case when &value >=2 then case when &value >=1 then 1 else 0 end + 2 else 0 end as b,
case when &value >=3 then case when &value >=2 then case when &value >=1 then 1 else 0 end + 2 else 0 end + 3 else 0 end as c
from dual
------其他解决方案--------------------
select
case when &value <=1 then 1 else 0 end as a,
case when &value <=2 AND &VALUE>1 then 3 WHEN &value <=1 THEN 2 else 0 end as b,
case when &value <=3 AND &VALUE>2 then 6 when &VALUE>1 then 5 WHEN &value <=1 THEN 4 ELSE 0 end as c
from dual
看一下是否为这样的效果
------其他解决方案--------------------
&value >=1
&value >=2
&value >=3
看着是不是有矛盾?
------其他解决方案--------------------
查过百度,没查到。。
------其他解决方案--------------------
分层嵌套或合并
------其他解决方案--------------------
楼主的条件是否搞错了
>=1--改为<=
大于等于 改为 小于等于
------其他解决方案--------------------
value的值 赋3, 其实就是想让他累加成 1 + 2+ 3 。。
------其他解决方案--------------------
哈哈。。一时急。。确实是 <=
------其他解决方案--------------------