substr help

Thread Solved

Join Date: Feb 2008
Posts: 6
Reputation: mamtha is an unknown quantity at this point 
Solved Threads: 0
mamtha mamtha is offline Offline
Newbie Poster

substr help

 
0
  #1
Aug 12th, 2009
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
  1. SELECT NVL (TRIM (SUBSTR (code,
  2. (INSTR (code,
  3. '_'
  4. )
  5. )
  6. + 1
  7. )
  8. ),
  9. '0'
  10. ) FROM temp_table;

Thanks,
Last edited by peter_budo; Aug 13th, 2009 at 12:39 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,104
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 128
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: substr help

 
0
  #2
Aug 13th, 2009
Try the following sample code.

  1. SELECT code,SUBSTR(code,INSTR(code,'-',1)+1,2) FROM table_name;
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 6
Reputation: mamtha is an unknown quantity at this point 
Solved Threads: 0
mamtha mamtha is offline Offline
Newbie Poster

Re: substr help

 
0
  #3
Aug 13th, 2009
Thanks for your help
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,104
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 128
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: substr help

 
0
  #4
Aug 14th, 2009
You are most welcome.
Last edited by debasisdas; Aug 14th, 2009 at 5:54 pm.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC