Reputation: 109
I am fairly new to SQL Server and was given the below case statement and I am having a hard time understanding what its doing.
I think its taking the 835 column checking to see if the claim value is (greater then 1) and if so then to relook at that column and bring in the Claim ID. And that is as far as I get in my thinking. Can some explain to me what it is doing?
case
when charindex(' ', ltrim(rtrim(ani.edi835claimicn))) > 1 then
substring(ltrim(rtrim(ani.edi835claimicn)), 1, charindex(' ', ltrim(rtrim(ani.edi835claimicn))) - 1)
else
ltrim(rtrim(ani.edi835claimicn))
end as icn
Upvotes: 1
Views: 416
Reputation: 272106
It simply extracts the substring before first space character in the input string (the value inside column ani.edi835claimicn
). If the string does not contain space then the input string is used as-is.
Upvotes: 1