Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

Re: Finding last Index of a String in HANA

$
0
0

Ok I tested this and it will work based on counting the number of spaces.  This will handle up to 2 spaces.  If you want more simply add some more WHEN conditions;  maybe not the prettiest but it will definitely work.

 

select

case when length(replace(RAW_ADDR,' ','**'))-length(RAW_ADDR) = 3

then

left(substr_AFTER(substr_AFTER(substr_AFTER(RAW_ADDR,' '),' '),' '),2)

when length(replace(RAW_ADDR,' ','**'))-length(RAW_ADDR) = 2

then

left(substr_AFTER(substr_AFTER(RAW_ADDR,' '),' '),2)

ELSE

RAW_ADDR END as MyNewString

from

FROM "BODS"."TABLE"


Viewing all articles
Browse latest Browse all 9165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>