Question

SUBSTRING_INDEX in Redshift?

  • 12 December 2014
  • 2 replies
  • 614 views

I am using a dimension like this in MySQL and need to convert it to Redshift:


    - dimension: major_version
type: number
sql: SUBSTRING_INDEX(${number}, '.', 1)

Is there something like SUBSTRING_INDEX in Redshift?


2 replies

Userlevel 3

Something like this should work…


SUBSTRING(${number},1, POSITION('.',${number}) -1))

You may have to play with it to check for edge conditions and such.

Userlevel 1

I’ve done something pretty something similar with SPLIT_PART Bucketing Users By Email Address - would that work?

Reply