I have value in a column like below ( space separated string )
1 4 7 5
4 5
1 4
1 3 4
I just need that 1 is 3 times,3 is 1 time, 4 is 4 times 5 is 2 times & 7 is 1 times.
Like below:
Value| count
-----+-------
1 | 3
3 | 1
4 | 4
5 | 2
7 | 1
I have tried like this:
SELECT value
FROM [dbo].tbl
CROSS APPLY STRING_SPLIT((SELECT DisCode FROM tbl), ' ');
but I get an error
Invalid object name 'STRING_SPLIT'
I have tried: String_split function is not splitting delimiters in SQL Server 2019 but did not get any solution.
Somebody asked about the lowest the compatibility level, but it's not possible for me to downgrade by server level because it's a running online server.('STRING_SPLIT' is not a recognized built-in function name )
Please give me a possible solution.