Skip to content
Advertisement

How to delete defined value from the begining of character in Oracle SQL?

I have table in Oracle SQL like below:

col1
--------
ABC|1234
ABC|55674
ABC|11

So I have in col1:

  • always “ABC|” at the begining of each value
  • different length of values after “ABC|”

I need result like below, so I need to delete “ABC|” from begining of each value

col1
---------------
1234
55674
11

How can I do that in Oracle SQL ?

Advertisement

Answer

A simple substring operation might be easiest here:

SELECT col1, SUBSTR(col1, 5) AS col1_out
FROM yourTable;

You could also do a replacement:

SELECT col1, REPLACE(col1, 'ABC|', '') AS col1_out
FROM yourTable;
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement