Page 1 of 1

Making MAX function work on CHAR column.

Posted: Fri Dec 04, 2015 11:33 am
by hp123
Hi,

MAX is a scalar function which gives the maximum value out of the column it is applied on. For a numeric column I understand how it can work but how MAX work on a CHAR column?

And what is the column has both numbers and characters.

Re: Making MAX function work on CHAR column.

Posted: Fri Dec 04, 2015 4:35 pm
by nicc
This kind of function is not based on the human interpretation of the data but the underlying encoding - EBCDIC on the mainframe. If your encoding was like this:

Code: Select all

x'30' represents human 9
x'31' represents human 8
x'32' represents human 7
x'33' represents human 6
x'34' represents human 5
x'35' represents human 4
x'36' represents human 3
etc
then 9 would be less than 3 because x'30' is less than x'36'