select * ,(价格*数量) as 合计,(case 合计 when > 100 then 10 else null end ) as 扣除 ,(合计-扣除) as 实数 from table

解决方案 »

  1.   

    select 货名,价格,数量,价格*数量 as  合计,
      case when 价格*数量>=100 then 10 else null end as 扣除 ,
      价格*数量 - (case when 价格*数量>=100 then 10 else null end) as  实
    数from yourtable
      

  2.   

    select 货名,价格,数量,价格*数量 as  合计,
      case when 价格*数量>=100 then 10 else null end as 扣除 ,
      价格*数量 - (case when 价格*数量>=100 then 10 else null end) as  实
    数from yourtable
      

  3.   

    select 货名,价格,数量,价格*数量 as  合计,
      case when 价格*数量>=100 then 10 else null end as 扣除 ,
      价格*数量 - (case when 价格*数量>=100 then 10 else null end) as  实
    数from yourtable
      

  4.   

    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)
      

  5.   

    若luoluo_lm(沧泫)兄的“实数”项能改为case表达式就更合理一些 :)
      

  6.   

    access:select 货名,价格,数量,价格*数量 as  合计,
      iif(价格*数量>=100,10,null) as 扣除 ,
      价格*数量 - iif(价格*数量>=100 ,10 ,null) as  实数
    from yourtable