select * from temp2 查询结果读数这列 读数
397452
400547
52961
538393
63669
684620
654050
1878145
1001892
106
30645
229740
181994
1244606
怎么样 在后面去掉两位 例如 397452 变成 3974
397452
400547
52961
538393
63669
684620
654050
1878145
1001892
106
30645
229740
181994
1244606
怎么样 在后面去掉两位 例如 397452 变成 3974
(所影响的行数为 142 行)服务器: 消息 536,级别 16,状态 3,行 1
向 substring 函数传递了无效的 length 参数。可能有的没有两位的怎么写
前提条件列长度一定要大于2,如果不一定请用case when ........then ....else .... end
select 读数 = left(读数 , len(读数) - 2) from temp2 where len(读数) > 2
union all
select 读数 from temp2 where len(读数) <= 2
select 读数= case when len(读数)<2 then 读数 else left(读数,len(读数)-2) end from temp2
select 397452
union all
select 400547
union all
select 52961
union all
select 538393
union all
select 63669select Result = case
when len(cast(number as varchar)) > 2 then left(cast(number as varchar),len(cast(number as varchar)) - 2)
else cast(number as varchar)
end
from @tab