select
(case when o.ordersource = '5' then to_char(o.orderamount * 0.994 - f.costmoney -o.splitprice - o.couponprice)
else to_char(o.orderamount - f.costmoney)
end) profitmoney
from flow_fullnote f,
flow_orderinfo o
(case when o.ordersource = '5' then to_char(o.orderamount * 0.994 - f.costmoney -o.splitprice - o.couponprice)
else to_char(o.orderamount - f.costmoney)
end) profitmoney
from flow_fullnote f,
flow_orderinfo o
where f.ordersno = o.ordersno
这段sql语句的意思是:
如果ordersource 的值为5,就给profitmoney赋值为:o.orderamount * 0.994 - f.costmoney -o.splitprice - o.couponprice;(profitmoney是自己声明的一个新的字段)
如果ordersource 的值为5以外的其他值,就给profitmoney赋值为:o.orderamount - f.costmoney;