Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

How to Split Column - response (1) by Wasif.Kabeer

$
0
0
Assuming that you are following a standard convention for splitting your address details (say separated by a comma: ","). CREATE TABLE test ( col1 VARCHAR(500) ) ; INSERT INTO test VALUES('House#1, Street#1, CityName'); SELECT option1 ,option2 ,option3 FROM ( SELECT col1 ,POSITION(',' IN col1) AS pos1 ,SUBSTRING(col1 FROM 1 FOR pos1-1) AS option1 ,SUBSTRING(col1 FROM pos1+1 FOR CHARACTER(col1)) AS substr1 ,POSITION(',' IN substr1) AS pos2 ,SUBSTRING(substr1 FROM 1 FOR pos2-1) AS option2 ,SUBSTRING(substr1 FROM pos2+1 FOR CHARACTER(substr1)) AS option3 FROM test )T; Output should be LIKE this:   Option1       Option2     Option3 House#1      Street#1    CityName

Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>