比如字段sid中用'|'分割的一些字符 a|b|c|d,需要通过sql查询出字符的个数是4.
可以使用如下脚本:
SELECT LEN(sid)-LEN(REPLACE(sid,'|',''))+1 'NUM1',COUNT(1)'NUM2' FROM dbo.FM_PurchaseRequest WHERE ISNULL(sid,'')<>'' GROUP BY LEN(sid)-LEN(REPLACE(sid,'|',''))+1 ORDER BY 附件个数 DESC
比如字段sid中用'|'分割的一些字符 a|b|c|d,需要通过sql查询出字符的个数是4.
可以使用如下脚本:
SELECT LEN(sid)-LEN(REPLACE(sid,'|',''))+1 'NUM1',COUNT(1)'NUM2' FROM dbo.FM_PurchaseRequest WHERE ISNULL(sid,'')<>'' GROUP BY LEN(sid)-LEN(REPLACE(sid,'|',''))+1 ORDER BY 附件个数 DESC