select 货名,价格,数量,价格*数量 as 合计, case when 价格*数量>=100 then 10 else null end as 扣除 , 价格*数量 - (case when 价格*数量>=100 then 10 else null end) as 实 数from yourtable
select 货名,价格,数量,价格*数量 as 合计, case when 价格*数量>=100 then 10 else null end as 扣除 , 价格*数量 - (case when 价格*数量>=100 then 10 else null end) as 实 数from yourtable
select 货名,价格,数量,价格*数量 as 合计, case when 价格*数量>=100 then 10 else null end as 扣除 , 价格*数量 - (case when 价格*数量>=100 then 10 else null end) as 实 数from yourtable
In oracle,use "decode": select price,amount,sum,deduct,sum-deduct from(select price,amount,price*amount sum,decode(sign(price*amount-100),1,10,0) deduct from table)
若luoluo_lm(沧泫)兄的“实数”项能改为case表达式就更合理一些 :)
access:select 货名,价格,数量,价格*数量 as 合计, iif(价格*数量>=100,10,null) as 扣除 , 价格*数量 - iif(价格*数量>=100 ,10 ,null) as 实数 from yourtable
case when 价格*数量>=100 then 10 else null end as 扣除 ,
价格*数量 - (case when 价格*数量>=100 then 10 else null end) as 实
数from yourtable
case when 价格*数量>=100 then 10 else null end as 扣除 ,
价格*数量 - (case when 价格*数量>=100 then 10 else null end) as 实
数from yourtable
case when 价格*数量>=100 then 10 else null end as 扣除 ,
价格*数量 - (case when 价格*数量>=100 then 10 else null end) as 实
数from yourtable
select price,amount,sum,deduct,sum-deduct from(select price,amount,price*amount sum,decode(sign(price*amount-100),1,10,0) deduct from table)
iif(价格*数量>=100,10,null) as 扣除 ,
价格*数量 - iif(价格*数量>=100 ,10 ,null) as 实数
from yourtable