Some SQL help

Database

Some SQL help

I am trying to help coworker. he has a table that stores multiple results (ie: data look like: ans1, ans2, ans3) and he needs to separate them out to use them in some code. i can not find a easy way to get the data out for him. (yes he can do this on the code side but he wants the sql query to do it for him)
1 REPLY
Enthusiast

Re: Some SQL help


sel Z.a,Z.b,Z.c from(
select position(',' in 'ans1,ans2,ans3') pos1
,substr('ans1,ans2,ans3',1,(pos1-1)) a
,substr('ans1,ans2,ans3',(pos1+1),position(',' in substr('ans1,ans2,ans3',(pos1+1)))-1) b
,substr(substr('ans1,ans2,ans3',(pos1+1)),(pos1+1)) c ) Z