select
    编号,
    协议价格 = (case when 协议号 is null then 单价*数量 else 协议号 end),
    总价
from
    表 a

解决方案 »

  1.   

    select 编号,case when 协议号 is null then 单价*数量 else 协议号 end as 协议价格,总价
    from 表a
      

  2.   


    declare @a table(编号 varchar(10),协议号 int,单价 decimal(18,1),数量 int,总价 int)
    insert @a values('001',3,0.1,100,10)
    insert @a values('002',null,0.4,50,10)
    select * from @aselect 编号,协议号=isnull(协议号,单价*数量),总价 from @a
      

  3.   

    不知道是不是这个效果。
    select
        编号,
        协议价格 = (case when 协议号 is null then convert(varchar,单价)+'*'+convert(varchar,数量) else 协议号 end),
        总价
    from
        表 a
      

  4.   

    select 编号 , 协议号=case when 协议号 is null then  单价*数量 else 协议号 end, 单价 , 数量 ,总价
    from a