phalondon
phalondon

Reputation: 305

extract string impala sql1

i have table like this:

testtime
4:6:7
11:2:8

how can i extract the minute and second from the string? i want something like this:

testtime minute second
4:6:7 6 7
11:2:8 2 8

thanks

Upvotes: 0

Views: 268

Answers (1)

nxl4
nxl4

Reputation: 734

You can use Impala's SPLIT_PART function to do this pretty easily:

SELECT  SPLIT_PART("4:6:7", ":", 2),
        SPLIT_PART("11:2:8", ":", 2)

You just need to feed the function an input string, delimiter, and field number within the newly delimited string.

Upvotes: 1

Related Questions