Re: Orderby two different columns - Mailing list pgsql-sql

From Tom Lane
Subject Re: Orderby two different columns
Date
Msg-id 18709.961775943@sss.pgh.pa.us
Whole thread Raw
In response to Orderby two different columns  ("Mitch Vincent" <mitch@venux.net>)
List pgsql-sql
"Mitch Vincent" <mitch@venux.net> writes:
> Ok, see applicant J? I need him to be above C.

Your example was about as transparent as mud, but maybe you are looking
to sort on MAX(resubmitted, created) or something like that?  Anyway
I'd think that sorting on some function of the two dates is probably
what you need to do.

I don't think we have a two-input MAX function like that, but it'd be
easy enough to fake it with a CASE expression.  Something like

... ORDER BY (CASE WHEN a > b THEN a ELSE b END) DESC;
        regards, tom lane


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Using substr with user defined types
Next
From: "Oliver Elphick"
Date:
Subject: Re: Orderby two different columns