Home » SQL & PL/SQL » SQL & PL/SQL » Using MAX() on a VARCHAR2 Column
Using MAX() on a VARCHAR2 Column [message #2710] Wed, 07 August 2002 11:25 Go to next message
jmd
Messages: 1
Registered: August 2002
Junior Member
Is it permissible to use the SQL MAX function on a VARCHAR2 column?

Thanks,
Jerry
Re: Using MAX() on a VARCHAR2 Column [message #2713 is a reply to message #2710] Wed, 07 August 2002 11:48 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
It is allowed, but the comparison will only be done on the first position and it is case-sensitive ('z' is a greater value than 'Z').

If you have numeric data in the varchar2 column, be sure to use the to_number function to allow the MAX to calculate correctly (otherwise '2' is greater than '10').
Re: Using MAX() on a VARCHAR2 Column [message #2896 is a reply to message #2710] Tue, 20 August 2002 07:26 Go to previous message
Abul Fazal
Messages: 39
Registered: February 2002
Member
Try the following query in sequence. Probably that will give u some idea.

Select ename from emp order by ename;

Select max(ename), min(ename) from emp;

Select ename from emp order by ename desc;

Select max(ename), min(ename) from emp;
Previous Topic: dba users
Next Topic: Parallel Query Option
Goto Forum:
  


Current Time: Tue Apr 23 16:31:55 CDT 2024