Making MAX function work on CHAR column.

RDBMS from IBM and IBM's Hierarchical DBMS and Transaction Manager (IMS DC).
Post Reply
hp123
New Member
Posts: 6
Joined: Mon Nov 09, 2015 10:51 am

Making MAX function work on CHAR column.

Post 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.
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Making MAX function work on CHAR column.

Post 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'
Regards
Nic
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DB2 and IMS DB/DC”