473,499 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to convert varchar into integer type in sql

12 New Member
Hi all,
i have two database enteries: 9shashi and 10shashi. both are of varchar type. how should i get maximum integer from these two values i.e,10.
If i use the query select max(id) from tablename; i am getting 9shashi. But i want to retrieve 10shashi out of there.
Please help me.
For help, i am using oracle 10g database express edition and not 'mysql'.
Aug 29 '13 #1
5 18282
buy domain
6 New Member
Expand|Select|Wrap|Line Numbers
  1. Select Cast([Column1] as INT) 
  2.  
Aug 29 '13 #2
rski
700 Recognized Expert Contributor
This is because for strings, max is taken in a lexicographical order.
You have to remove non-number characters and use to_number
Expand|Select|Wrap|Line Numbers
  1. select max(to_number(regexp_replace(column_name,'[[:alpha:]]', ''))) from test;
  2.  
Aug 29 '13 #3
shashikala
12 New Member
thankyou both for answering. :) well rski method works smoothly. but i have another question, what does [[:alpha:]] does in the query?
Aug 30 '13 #4
debasisdas
8,127 Recognized Expert Expert
For that you need to understand Regular Expression.
Sep 3 '13 #5
rski
700 Recognized Expert Contributor
See here
http://psoug.org/reference/regexp.html
Sep 3 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

28
2457
by: Timothy Madden | last post by:
Hello I've read here that only C language has a standard 64bit integer. Can you please tell me what are the reasons for this ? What is special about C language ? Can you please show me some...
5
11570
by: Anton | last post by:
I have a table of zip codes, some with Canadian zips. I'd like to take a zip code and search for nearby zips. For example: Dim theZip As Integer = textbox1.text ....Parameter.Add(@ziplow,...
4
1811
by: FatboyCanteen | last post by:
If I have a textbox, Let use to input a text. I want to check the input text is integer type or no I use isnum() to validate it, but double type also pass the validation. I don't want to use Field...
16
117150
by: akarui.tomodachi | last post by:
What is the most easiest way to convert an integer value to ASCII character format ? I tried with sprintf(). It works. Is there any other way to do that ? Objective:: I like to convert an...
43
8376
by: Steven T. Hatton | last post by:
http://public.research.att.com/~bs/bs_faq2.html#int-to-string Is there no C library function that will take an int and convert it to its ascii representation? The example Bjarne shows in his faq...
1
14590
by: Woodies_46 | last post by:
Ok i know this is simple but i just don't know the syntax. What I have is a bunch of values and i want to be able to display them as money values with a $ in front. eg. 16000000 1000 160000
10
5604
by: rodrigo.gloria | last post by:
I am trying to convert a integer to an address of a function pointer. I want to encrypt the pointer and then do some validation, afterwards i will decrpyt the pointer back to an address. Can...
10
3158
by: Mike S | last post by:
Does anyone know the logic behind why in VB.NET the result of a floating-point division ('/') is -rounded- on being converted to an integer type, such as with statements like Dim x As Integer =...
3
1743
by: veeman | last post by:
Can someone please write an example containing one element which value is integer type, and one attribute which value is also integer type: Is it something like this: <SomeAttribute...
27
2793
by: fdu.xiaojf | last post by:
Hi, String formatting can be used to converting an integer to its octal or hexadecimal form: '307' 'c7' But, can string formatting be used to convert an integer to its binary form ?
0
7132
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7009
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4602
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3103
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.