sqlstringhive

Dividing STRING with delimiters


I have to divide a STRING value with the "." delimiter into two values. Like this:

Input:

var0
9342102124501.0000001236

Output:

var1 var2
9342102124501 0000001236

Solution

  • You can use string-function split, which accepts a regex and returns an array:

    select var0,
        split(var0, '[\.]')[0] as var1,
        split(var0, '[\.]')[1] as var2
    from mytable