Clark Christensen wrote:
I've read through numerous discussions here about comparing values with null, 
and how SQLite functions work with null values, and I thought I understood.

Now it seems appropriate to use the max(col1, col2) function to find the latest 
of two dates (integer Unix times), and some rows will contain null in one 
column or the other.  But, max() always returns null when one of its args is 
null.  That just seems backwards :-))

FWIW, I'm on 3.3.12 on both Windows and Linux.

Any help is appreciated.

Clark,

You must reassign the value used for the comparison if it is null.

The coalesce function will return the first non null value in its arguments, and this may be all you need. If you only want the value from col2 if col1 is null then simply use

   coalesce(col1, col2)

You will only get a null result if both columns are null.

If you really wan the max of the two columns you can use coalesc to convert nulls into zeros for the max function.

   max(coalesce(col1, 0), coalesce(col2, 0))

This will give a result of zero if both columns are null.

HTH
Dennis Cote

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to