How to split a string in ANSI-SQL

2.6k Views Asked by At

How can I split a column value in ANSI SQL? I use VectorWise DB and VW doesn't support split method.

How can I solve it?

SELECT
       stars,
       LEFT(stars, POSITION(',', stars + ',') - 1) AS star1,
       CASE WHEN CHARACTER_LENGTH(oyuncu) - CHARACTER_LENGTH(REPLACE(stars, ',', '')) > 0
          THEN TRIM(SUBSTRING(stars, POSITION(',', stars) + 1,
              POSITION(',', stars + ',', POSITION(',', stars) + 1) 
              - POSITION(',', stars) - 1))
          ELSE NULL
          END AS star2,
       CASE WHEN CHARACTER_LENGTH(stars) - CHARACTER_LENGTH(REPLACE(stars, ',', '')) > 1
          THEN TRIM(SUBSTRING (stars, POSITION(',', stars + ',',
              POSITION(',', oyuncu) + 1) + 1, CHARACTER_LENGTH(stars)))
          ELSE NULL
       END AS star3
    FROM administrator.dnm

I added a screenshot a What I want after the changes. But I haven't got enough reputation for What I want after the changes :(

ANSI doesn't support some specific methods that T-SQL has.

1

There are 1 best solutions below

0
DejanLekic On

Go to http://docs.actian.com , click on "Options", pick Actian Vector 3.5, and in the navigator pick the "Vector 3.5 SQL Language Guide".

The SUBSTR and SUBSTRING functions are explaned here: Elements of SQL Statements -> SQL Functions -> String Functions -> SUBSTR Function . Your example should work on Vector 3.5.