Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get remaining of string (right) after x number of specific character - Snowflake

I am trying to get the remaining string (from right) after x number of a specific character... ex:

D-ERT-ESTTE
D-EST-AER-EJEL
D-E-AD

I would like to get all string data after the second '-'

Results Expected:

ESTTE
AER-EJEL
AD

I have tried modifying substring(SKU,1,regexp_instr(SKU,'-',1,2)-1)

, however this is only giving me giving me everything to the left of the second '-'... I need from the right though

Update: Looks like maybe the below works:

substr(SKU,regexp_instr(SKU,'-',1,2)+1)
like image 523
NIC3301 Avatar asked Oct 27 '25 13:10

NIC3301


1 Answers

try this

select fld1, SPLIT_PART(fld1,'-',3), substr(fld1,regexp_instr(fld1,'-',1,2)+1), regexp_instr(fld1,'-',1,2) from (
select 'D-ERT-ESTTE' fld1 from dual union all
select 'D-EST-AER-EJEL' from dual union all
select' D-E-ADF' from dual );
like image 140
Himanshu Kandpal Avatar answered Oct 29 '25 05:10

Himanshu Kandpal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!