日期:2014-05-18 浏览次数:20562 次
select len(ltrim(col))-len(replace(ltrim(col),'1','')) as cnt from tb
------解决方案--------------------
select len('13966171891')-replace('13966171891','1','')
------解决方案--------------------
declare @str varchar(100) set @str = '13966171891' select len(ltrim(@str))-len(replace(ltrim(@str),'1','')) /************* ----------- 4
------解决方案--------------------
DECLARE @STR VARCHAR(MAX),@STR_SEARCH VARCHAR(MAX) SELECT @STR='13966171891',@STR_SEARCH='1' SELECT COUNT(DISTINCT CHARINDEX(@STR_SEARCH,@STR,NUMBER)) FROM MASTER..SPT_VALUES WHERE TYPE='P' AND NUMBER BETWEEN 1 AND LEN(@STR)
------解决方案--------------------
select len(ltrim('13966171891'))- len(replace(ltrim('13966171891'),'1','')) (无列名) 4
------解决方案--------------------
select * from(select len(ltrim(col2))-len(replace(ltrim(col2),'1','')) as cnt
from tb)a where cnt>=3
------解决方案--------------------
select len('13966171891')-replace('13966171891','1','')
------解决方案--------------------
select len('13966171891')-replace('13966171891','1','')