I need to derive last 2 numbers after the '-' from the code column.
example if the code is 76767-99 then I need a query to return only 99. I am using substr and instr functions but not getting what I want. Please help me correct the below query.
code - 76767-99

select NVL (TRIM (SUBSTR (code,
                                             (INSTR (code,
                                                     '_'
                                                    )
                                             )
                                           + 1
                                          )
                                  ),
                             '0'
                            ) from temp_table;

Thanks,

Recommended Answers

All 3 Replies

Try the following sample code.

SELECT code,substr(code,instr(code,'-',1)+1,2) from table_name;

Thanks for your help

You are most welcome.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.