Re: Orderby two different columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Mitch Vincent" <mitch(at)venux(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Orderby two different columns
Date: 2000-06-23 15:59:03
Message-ID: 18709.961775943@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Mitch Vincent" <mitch(at)venux(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Oliver Elphick 2000-06-23 16:07:20 Re: Orderby two different columns
Previous Message Tom Lane 2000-06-23 15:52:25 Re: Using substr with user defined types