Chris90
Chris90

Reputation: 1998

Creating a column containing only a specific value of another column

I have table such as

column
abcx sample 6.5oz
bbcd sku 2ct
tty 80z
rre pool 65g box

How can I create a new column in my select statement that would just give me what the size of each row value is? ( 6.50z, 2ct, 80z, 65g)

desired output:

size
6.5oz
2ct
90z
65g

Upvotes: 0

Views: 39

Answers (1)

Marcin Zukowski
Marcin Zukowski

Reputation: 4739

The question is not specified precisely.

Here's a solution assuming you're interested in "a sequence of digits, possibly containing a dot, immediately followed by a sequence of lowercase letters". If so, this should do it:

select col, regexp_substr(col, '[\\d\\.]+[a-z]+') from test;

If this is not what you're looking for, please make the question very specific

Upvotes: 2

Related Questions