select 
cast(left(FLB_Lbbm,2)as float) as 商品大类,
flb_lbbm as 商品类别,
fsm_spbm as 商品编码,
fsm_spmc as 商品名称,
fsm_sppp as 商品品牌,
(case fsm_spmc when 'fsm_spmc like'%原装%'' then '是' else '否' end) as 是否原装
from TB

解决方案 »

  1.   

    忘了说明问题,上面的语句我想把FSM_SPMC包含原装的做个判断,但总有错误提示.提示内容:
    服务器: 消息 207,级别 16,状态 3,行 1
    列名 '原装' 无效。
      

  2.   

    --try
    select 
    cast(left(FLB_Lbbm,2)as float) as 商品大类, 
    flb_lbbm as 商品类别, 
    fsm_spbm as 商品编码, 
    fsm_spmc as 商品名称, 
    fsm_sppp as 商品品牌, 
    (case  when   patindex('%原装%' ,fsm_spmc)>0 then '是' else '否' end) as 是否原装 
    from TB
      

  3.   

    引号错误
    select 
    cast(left(FLB_Lbbm,2)as float) as 商品大类, 
    flb_lbbm as 商品类别, 
    fsm_spbm as 商品编码, 
    fsm_spmc as 商品名称, 
    fsm_sppp as 商品品牌, 
    (case fsm_spmc when fsm_spmc like'%原装%' then '是' else '否' end) as 是否原装 
    from TB