select name from table
请问怎样使输出时,name的长度超过20时加 ".. "显示,不超过时不显示 ".. "呢?
select left(name,20) as name from talbe这个什么时候都显示 ".. "的不想这样
------解决方案--------------------
select left(name,20)+ '.. ' from t0126
where len(name)> =20
union all
select name from t0126
where len(name) <20
------解决方案--------------------
用Case语句,如果长度 > 20,那么就取左边的20个字符,再加上‘..’
否则就取name
select
case when len(name) > 20 then substring(name,1,20)+ '.. '
else name
end name
from table
------解决方案--------------------
select '姓名 '=case when len(name)> 20 then left(name,20)+ '.. ' else name end from talbe
------解决方案--------------------
--try
select
name=case when len(name)> 20 then left(name, 20)+ '... ' else name end
from table