Finding last index of a string in Oracle

JDunkerley picture JDunkerley · May 13, 2009 · Viewed 122.3k times · Source

I need to find the last index of a string (e.g. -) within another string (e.g. JD-EQ-0001 in Oracle's SQL (version 8i). Is there a way to do this with INSTR() or another function?

Answer

jim0thy picture jim0thy · May 13, 2009

Use -1 as the start position:

INSTR('JD-EQ-0001', '-', -1)