I have a column value e.g. 'IC123456IC789123'. The value is an aggregation from different systems, so could be in the form of numbers or letters/numbers with no fixed format e.g. 921253 X4525186 IC543534
Before the numbers can be used in another join, the data needs to be cleaned. The is a consistent pattern with one particular system that seems to combined two numbers e.g. the example with the IC prefix
I need to create two rows for this column, but only in this circumstance. the other data should be passed through and they should be distinct values (but in some cases, per the example, they are duplicated in a column)
results
'IC123456'
'IC789123'
But it should only create one row, if it is a duplicate
'IC123456IC123456'
'IC123456'
'IC123456'
results
'IC123456'
I tried REGEXP_SUBSTR('account','number','[^IC]',1,2) AS "PARTS"
but only gives me the numbers without the 'IC' (which i need to retain). Also, gives them on a new column, but i want to retain in the 'number column' it should also return every other number which does not contain 'IC' in it.
You can split the string in 2 rows by IC keyword using Connect by clause and then use the distinct keyword to get the unique value -
Demo.