Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract letters and numbers from a char field

Status
Not open for further replies.

Wabush

Programmer
Jan 15, 2001
31
US
Hi there,

I have a varchar2(32) field (asset_tag) that contains data like ;
PC1234
INV1234
PCM1234

The first letters indicating inventory category, and the numbers indicate the sequence.

Is there a way to show in a query the last used number of each Category? This gives the asset managers a way to see the number they should use next for their asset tag..

Thanks for any help!
 
to_number(translate(asset_tag,'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'0123456789'))
 
What about this:
Code:
SELECT RTRIM (asset_tag, '0123456789'), 
       MAX(TO_NUMBER(LTRIM(
       asset_tag,'ABCDEFGHIJKLMNOPQRSTUVWXYZ')))
FROM test
GROUP BY RTRIM (asset_tag, '0123456789');
[\code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top