GeekInterview.com
Series: Subject: Topic:
Question: 3 of 190

How can you retrieve the numeric values from varchar2 type column?

Hi Friends, One table is there. It is having varchar2 type column and this column having both numeric and alphanumeric values but I want to retrieve only numeric related values from that table. If it is possible then say the answer plz... I will wait for ur tremendous answer...
Asked by: Balapradeep Reddy | Member Since Feb-2012 | Asked on: Feb 10th, 2012

View all questions by Balapradeep Reddy   View all answers by Balapradeep Reddy

Showing Answers 1 - 8 of 8 Answers
chakri292

Answered On : Feb 11th, 2012

View all answers by chakri292

Hi, You can use regexp. for e.g.,

Code
  1. SELECT to_number(regexp_replace(hello123,[[:alpha:]],)) FROM dual;

Output:
--------------
123

  
Login to rate this answer.
Balapradeep

Answered On : Feb 14th, 2012

Code
  1. SELECT * FROM table_name WHERE regexp_like(column_name,^[0-9]+$);

Yes  2 Users have rated as useful.
  
Login to rate this answer.

Code
  1. SELECT * FROM table_name WHERE regexp_like(column_name,^[0-9]+$);

  
Login to rate this answer.
samarendra

Answered On : Apr 3rd, 2012

Code
  1. SELECT column1 FROM TABLE WHERE column1 NOT LIKE %[^0-9]%

  
Login to rate this answer.
rohitosu

Answered On : Apr 3rd, 2012

View all answers by rohitosu

Query is missing quotes. The corrected query is..

Code
  1. SELECT * FROM table_name WHERE regexp_like(column_name,^[0-9]+$);

  
Login to rate this answer.
Sushma S

Answered On : Apr 9th, 2012

Code
  1. SELECT * FROM table_name WHERE regexp_like(column_name,^[0-9]+$);

  
Login to rate this answer.
Sudipto

Answered On : Apr 17th, 2012

Code
  1. SELECT * FROM table_name WHERE regexp_like (column_name, ^[0 - 9] + $);

  
Login to rate this answer.
Nisa

Answered On : Apr 17th, 2012

Using regexp_replace function

Code
  1. SELECT to_number(regexp_replace(abc123efg456kjhdf,[[:alpha:]]))
  2. FROM dual;

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.