Each record contains two fields - field1 and field2. Both contain dates.
For reach record: 1 field might have been filled in, for another it might be 2 of the fields or none at all.
I'd like to in the most efficient way possible order them based on this.
So it would compare field1 and field2 for a record and find which one has the latest date. It would then list all of the records in order based on this and then display the records that don't have any kind of entry.
I had it sorted for just field1 like this:
order("CASE WHEN field1 IS NULL THEN 1 ELSE 0 END, field1 desc"
But when I try and introduce field 2 into the query it doesn't give me the results that I would expect.
Any ideas?