I have such field that has values like:
- George,George,George
- Ann,Ann
- John,Ann,John
- Liza,Jack
- Nina
- Leticia
- Leny,Ann,Mary,Mary,Ann
I'm trying to create the field according to the filed above that will have values like:
- George
- Ann
- John,Ann
- Liza,Jack
- Nina
- Leticia
- Leny,Ann,Mary
I used the following SQL code:
Case when Charindex ( ' , ' , [data I have] ) > 0 then substring ( [data I have] , 0 , charindex ( ' , ' , [data I have] , 0 ) else [data I have] end)
This code deals with 1,2,5,6 cells but fails in case of 3,4,7 because it leaves John in 3., Jack in 4. and Ann in 7.
Could you please help to find the way how to fix it?
Thank you