描述
现有strings表如下:
id指序列号;
string列中存放的是字符串,且字符串中仅包含数字、字母和逗号类型的字符。
请你统计每个字符串中逗号出现的次数cnt。
以上例子的输出结果如下:
string长度减去 将逗号替换为空字符串的长度 即是 逗号数量
select id, LENGTH(string) - LENGTH(replace(string, ',','')) cnt from strings;
描述
现有strings表如下:
id指序列号;
string列中存放的是字符串,且字符串中仅包含数字、字母和逗号类型的字符。
请你统计每个字符串中逗号出现的次数cnt。
以上例子的输出结果如下:
string长度减去 将逗号替换为空字符串的长度 即是 逗号数量
select id, LENGTH(string) - LENGTH(replace(string, ',','')) cnt from strings;