dbTalk Databases Forums  

extract numeric part from address

comp.database.oracle comp.database.oracle


Discuss extract numeric part from address in the comp.database.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David Chang
 
Posts: n/a

Default extract numeric part from address - 02-10-2004 , 03:06 AM






I am trying to do some analysis on customer's locality, so I'd like to
extract numeric part from address.

Here is how the table looks like

Table Member

first_name last_name address1 address2
state zip
======= ======= =================== ===== === ===
Tom whatever 1200 Evelyn Ave, #121
CA 94102

What I want to do is to write some sql to extract 1200 from Tom's address1.
Can any one give me some hint? Some sample code will be greatly appreciated
!!

David



Reply With Quote
  #2  
Old   
sybrandb@yahoo.com
 
Posts: n/a

Default Re: extract numeric part from address - 02-10-2004 , 08:35 AM






"David Chang" <chang_dj (AT) yahoo (DOT) com> wrote

Quote:
I am trying to do some analysis on customer's locality, so I'd like to
extract numeric part from address.

Here is how the table looks like

Table Member

first_name last_name address1 address2
state zip
======= ======= =================== ===== === ===
Tom whatever 1200 Evelyn Ave, #121
CA 94102

What I want to do is to write some sql to extract 1200 from Tom's address1.
Can any one give me some hint? Some sample code will be greatly appreciated
!!

David
substr(<column>, 1, instr(...) -1 )

You fill in the ... as an exercise.


Sybrand Bakker
Senior Oracle DBA


Reply With Quote
  #3  
Old   
Ron
 
Posts: n/a

Default Re: extract numeric part from address - 02-10-2004 , 10:50 AM




Hello David,

In case if number always located at the beginning of the filed and space
delimited , you can use below:

select substr(address, 1, instr(address,' ',1) ) from <table>;

If not, then you can use PL/SQL to scrub the address.

Regards,

Ron
DBA Infopower
http://www.dbainfopower.com
Standard disclaimer:
http://www.dbainfopower.com/dbaip_ad...isclaimer.html



"David Chang" <chang_dj (AT) yahoo (DOT) com> wrote

Quote:
I am trying to do some analysis on customer's locality, so I'd like to
extract numeric part from address.

Here is how the table looks like

Table Member

first_name last_name address1 address2
state zip
======= ======= =================== ===== === ===
Tom whatever 1200 Evelyn Ave, #121
CA 94102

What I want to do is to write some sql to extract 1200 from Tom's
address1.
Can any one give me some hint? Some sample code will be greatly
appreciated
!!

David





Reply With Quote
  #4  
Old   
sybrandb@yahoo.com
 
Posts: n/a

Default Re: extract numeric part from address - 02-11-2004 , 02:51 AM



"Ron" <support (AT) dbainfopower (DOT) com> wrote

Quote:
Hello David,

In case if number always located at the beginning of the filed and space
delimited , you can use below:

select substr(address, 1, instr(address,' ',1) ) from <table>;

If not, then you can use PL/SQL to scrub the address.

Regards,

Ron
DBA Infopower
http://www.dbainfopower.com
Standard disclaimer:
http://www.dbainfopower.com/dbaip_ad...isclaimer.html



"David Chang" <chang_dj (AT) yahoo (DOT) com> wrote in message
news:8a1Wb.209671$Rc4.1720145 (AT) attbi_s54 (DOT) ..
I am trying to do some analysis on customer's locality, so I'd like to
extract numeric part from address.

Here is how the table looks like

Table Member

first_name last_name address1 address2
state zip
======= ======= =================== ===== === ===
Tom whatever 1200 Evelyn Ave, #121
CA 94102

What I want to do is to write some sql to extract 1200 from Tom's
address1.
Can any one give me some hint? Some sample code will be greatly
appreciated
!!

David


Due to the basic nature of the OP's request:
please try to learn people how to fish, do not fish on their behalf.
You are disclosing way too much. OP should *learn* sql, he should not be spoon fed.

Sybrand Bakker
Senior Oracle DBA


Reply With Quote
  #5  
Old   
UNIXNewBie
 
Posts: n/a

Default Re: extract numeric part from address - 02-19-2004 , 10:22 PM



Assuming we only have 1 space between the street number and the name of the
street I would try this

SELECT SUBSTR(ADDRESS, INSTR(ADDRESS,' ',1)) FROM <TABLE>

The examle below would return the number part.

If you wanted to be sure you might have to resort to PL/SQL if there are
more that 1 space.



J.







<sybrandb (AT) yahoo (DOT) com> wrote


Quote:
"Ron" <support (AT) dbainfopower (DOT) com> wrote

Hello David,

In case if number always located at the beginning of the filed and
space
delimited , you can use below:

select substr(address, 1, instr(address,' ',1) ) from <table>;

If not, then you can use PL/SQL to scrub the address.

Regards,

Ron
DBA Infopower
http://www.dbainfopower.com
Standard disclaimer:
http://www.dbainfopower.com/dbaip_ad...isclaimer.html



"David Chang" <chang_dj (AT) yahoo (DOT) com> wrote in message
news:8a1Wb.209671$Rc4.1720145 (AT) attbi_s54 (DOT) ..
I am trying to do some analysis on customer's locality, so I'd like to
extract numeric part from address.

Here is how the table looks like

Table Member

first_name last_name address1
address2
state zip
======= ======= =================== ===== === ===
Tom whatever 1200 Evelyn Ave, #121
CA 94102

What I want to do is to write some sql to extract 1200 from Tom's
address1.
Can any one give me some hint? Some sample code will be greatly
appreciated
!!

David



Due to the basic nature of the OP's request:
please try to learn people how to fish, do not fish on their behalf.
You are disclosing way too much. OP should *learn* sql, he should not be
spoon fed.

Sybrand Bakker
Senior Oracle DBA



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.