Home » RDBMS Server » Server Administration » Query for selecting maximum value from character field
Query for selecting maximum value from character field [message #371571] Wed, 08 November 2000 23:20 Go to next message
Pravin Kulkarni
Messages: 2
Registered: November 2000
Junior Member
I am facing one problem. I had a table, which contains a column with character data type. It consists of Numeric values as well as Character values. I want Maximum of Numeric values using only one SQL statement.I know that it is possible using PL/SQL.Is it possible using one SQL statement?
Re: Query for selecting maximum value from character field [message #371573 is a reply to message #371571] Thu, 09 November 2000 03:54 Go to previous messageGo to next message
John R
Messages: 156
Registered: March 2000
Senior Member
SELECT MAX(NVL(
REPLACE(
TRANSLATE(UPPER(Field)
,'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
,' (spaces as long as the quoted string)'
),' ',''
)
),0)
FROM Table

This translates all non-numeric characters into spaces (yo may want to add punctuation chrs to the list) and then truncates all spaces, leaving you with a numeric
field.

(Sorry about the formatting, but this isn't th most friendly editor ever)
Re: Query for selecting maximum value from character field [message #371586 is a reply to message #371573] Fri, 10 November 2000 01:15 Go to previous message
Pravin Kulkarni
Messages: 2
Registered: November 2000
Junior Member
Thank You John R. It really helpfull for me.
Previous Topic: Need help on Oracle d/b and Oracle Application server application development
Next Topic: How to access COM components from the stored Procedures
Goto Forum:
  


Current Time: Thu May 02 12:44:52 CDT 2024