Select Query Question

admin

Administrator
Staff member
Hi.
I hope someone will answer this more of an SQL question:

I want to compare 2 columns in an SQL select statement so that the resulting column only has the higher value.

To simplify things something like

select func(col1, col2) from table1

So i need something like the 'func' function in the above select statement, but the resultset is only 1 column whose record in each row is the greater of col1 and col2.

Example.
TABLE table1

col1 col2
-----------
1 4
3 0

select func(col1, col2) from table1

resultset:

-----
4
3


Thanks in advance for your assistance. I myself was unable to find any function in DB2 (the db engine that I am using) called 'greatest' or something...
 
Back
Top