你把substring('Itemno',4,2) <'30' 用select substring('Itemno',4,2) <'30' from 表查出来自然就清楚了
明白了,可能因为Itemno是Varchar类型,有办法转换么?
case那么多,考虑考虑用查询及临时表。
这样改吧 type in ('SLML') then (case when Itemno like 'YPY%' then (case when substring('Itemno',4,2) <'30' then Sprice18 else Sprice17 改: case when type in ('SLML') and Itemno like 'YPY%' and substring('Itemno',4,2) <'30' then Sprice18 else Sprice17 end
case when type in ('XLML') then ( case when Itemno like 'YPY%' then( case when substring('Itemno',4,2) <'30' then SPrice12 else SPrice11 end) 你的表结构贴出来,不然大家不清楚你的要求! 请注意你的书写格式
Server: Msg 245, Level 16, State 1, Line 1 将 varchar 值 'mn' 转换为数据类型为 int 的列时发生语法错误。
明白了,可能因为Itemno是Varchar类型,有办法转换么?
type in ('SLML') then (case when Itemno like 'YPY%' then (case when substring('Itemno',4,2) <'30' then Sprice18 else Sprice17
改:
case when type in ('SLML') and Itemno like 'YPY%' and substring('Itemno',4,2) <'30'
then Sprice18 else Sprice17 end
then (
case when Itemno like 'YPY%'
then(
case when substring('Itemno',4,2) <'30'
then SPrice12
else SPrice11 end) 你的表结构贴出来,不然大家不清楚你的要求!
请注意你的书写格式
Server: Msg 245, Level 16, State 1, Line 1
将 varchar 值 'mn' 转换为数据类型为 int 的列时发生语法错误。
substring('Itemno',4,2) <30 ---> substring(Itemno,4,2) <30