在 SQL 中是否可以用分隔符分割数字并计算它们?

Is it possible in SQL to split the numbers by the delimiter and count them?

我在 SQL table 中有一列,其中包含如下项目列表:99987995\|M99987995\|99987995\|。我想用分隔符 (/|) 拆分项目,然后计算项目数。例如,我将从列表中获得 3 个项目,即 99987995, M99987995, 99987995。附件也是一张图片以及结果的样子。对于 header 2 中的每个组,我想计算 header 3 中的项目数。现在 header3 也有一些 null/empty 字段。enter image description here

试试这个代码:

SELECT [header2] as Header, Cnt as [Number of items] from [table] t
    CROSS APPLY (
        SELECT COUNT( [value]) Cnt FROM STRING_SPLIT( REPLACE( [header3], '\|', ','), ',')     
    )x