如何写sql语句统计每个字段中“/”出现的个数?

/newsPic/200807/29/2903
/newsPic/200807/30/200873015158139
/newsPic/200904/25/2982

第1个回答  2014-12-18
DECLARE @str1 VARCHAR(100),@str2 VARCHAR(100),@str3 VARCHAR(100)
SET @str1 = '/newsPic/200807/29/2903'
SET @str2 = '/newsPic/200807/30/200873015158139'
SET @str3 = '/newsPic/200904/25/2982'
SELECT LEN(@str1)-LEN(REPLACE(@str1,'/','')),LEN(@str2)-LEN(REPLACE(@str2,'/','')),LEN(@str3)-LEN(REPLACE(@str3,'/',''))

第2个回答  2014-12-18
oracle下可以这样:
select length(regexp_replace('/newsPic/200807/29/2903','[^/]+','')) from dual;

--结果为4追问

如果是access呢

本回答被网友采纳
相似回答