Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: look last two digits
On 2007-04-25, cptkirkh <khill_at_scic.com> wrote:
> If I want to look up the last two digits of a number and I don't know
> how many digits the number is what SQL query can I use? I tried the
> following
>
> select ID from table where substr(id,6) = 30; and it will only work if
> the number of digits is constant. What if I go from a 7 digit number
> to a 6 digit number? Thanks for your help.
SQL> select substr(89094,-2) from dual;
SU
-- 94 SQL> select substr(89094.4902,-2) from dual; SU -- 02 hth, Rene -- Rene Nyffenegger http://www.adp-gmbh.chReceived on Wed Apr 25 2007 - 17:23:11 CDT