Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Fetching Max value from NVARCHAR column

 
Neelima Mohan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Thanks,
Neelima
 
Agador Paloi
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
Agad
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic