File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Oracle/OAS and the fly likes Fetching Max value from NVARCHAR column Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Fetching Max value from NVARCHAR column" Watch "Fetching Max value from NVARCHAR column" New topic

Fetching Max value from NVARCHAR column

Neelima Mohan

Joined: May 23, 2010
Posts: 27

How do I fetch the Max value of the data stored in a NVARCHAR column. Presently only numbers are stored in this column.
Max(AliasID) is not returning me the collect value.
Is there a way to fetch these numberic values from NVARCHAR col?
Now don't ask me why it was implemented that way...its an already existing system.

Agador Paloi
Ranch Hand

Joined: Jan 24, 2006
Posts: 118
You seem certain that they are all numbers in the column. You can use to_number() function
to convert to numbers and get the max .

If by chance one is not a number , it will throw an invalid number error.

You might consider writing a small function to convert to a number and if it is
invalid number return a null or 0 ?

good luck,
I agree. Here's the link:
subject: Fetching Max value from NVARCHAR column
It's not a secret anymore!