× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



After reading your subject line again, I can see another method that may be
more inline with trimming:

SELECT TRIM(LEADING 'A' FROM
TRIM(LEADING 'B' FROM
TRIM(LEADING 'C' FROM myField)))
FROM myLib/myFile

Elvis

Celebrating 10-Years of SQL Performance Excellence on IBM i5/OS and OS/400
http://centerfieldtechnology.com/training.asp


-----Original Message-----
Subject: RE: SQL question - trim leading alphabetic characters

Based solely on the sample set you provided, this ought to work:

SELECT REPLACE(REPLACE(myField,'ABC',''),'A','') FROM myLib/myFile

If you're on a release that doesn't support REPLACE function, look into
TRANSLATE.

Elvis

Celebrating 10-Years of SQL Performance Excellence on IBM i5/OS and OS/400
http://centerfieldtechnology.com/training.asp


-----Original Message-----
Subject: SQL question - trim leading alphabetic characters

Does SQL have a relatively easy way to do this mapping?

ABC123 -> 123
ABC123DEF -> 123DEF
A1B2 -> 1B2
...

I've done something similar before as a "one off", but I can't remember
whether it was an RPG program or SQL or SEQUEL. Of course, now needed
again (one year later), I can't find the object!

TIA,


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.