用decode函数可以解决这样的多选问题,在这里可以这样: 先建立一个子查询: select t.*,'a' f1 from Table_A t where t.Value>0.05 union all select t.*,'b' f1 from Table_A t where t.Value<-0.05 union all select t.*,'c' f1 from Table_A t where t.Value>=-0.05 and t.Value<=0.05然后就可以用连接来做了呀 select l.date,decode(ll.f1,'a',-l.value,'b',l.value,null) from Table_B l, (select t.*,'a' f1 from Table_A t where t.Value>0.05 union all select t.*,'b' f1 from Table_A t where t.Value<-0.05 union all select t.*,'c' f1 from Table_A t where t.Value>=-0.05 and t.Value<=0.05 ) ll where l.Date=ll.Data
先建立一个子查询:
select t.*,'a' f1 from Table_A t where t.Value>0.05
union all
select t.*,'b' f1 from Table_A t where t.Value<-0.05
union all
select t.*,'c' f1 from Table_A t where t.Value>=-0.05 and t.Value<=0.05然后就可以用连接来做了呀
select l.date,decode(ll.f1,'a',-l.value,'b',l.value,null)
from Table_B l,
(select t.*,'a' f1 from Table_A t where t.Value>0.05
union all
select t.*,'b' f1 from Table_A t where t.Value<-0.05
union all
select t.*,'c' f1 from Table_A t where t.Value>=-0.05 and t.Value<=0.05
) ll
where l.Date=ll.Data
when a.value > 0.05 then - b.value
when a.value <-0.05 then b.value
else null end value
from a,b
where a.date = b.date