Re: deciding on one of multiple results returned

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Wes James <comptekki(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>, David Johnston <polobo(at)yahoo(dot)com>, Seth Gordon <sethg(at)ropine(dot)com>
Subject: Re: deciding on one of multiple results returned
Date: 2012-12-21 18:22:58
Message-ID: CAOR=d=2Mu3_rKK55h=t5p9KaYwOFcsC2MvWwFcSebcb8cSyGmg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Dec 21, 2012 at 10:28 AM, Wes James <comptekki(at)gmail(dot)com> wrote:
> David and Seth Thanks. That helped.
>
>
> When I have
>
> select distinct on (revf3) f1, f2, f3, revers(f3) as revf3 from table order
> by revf3
>
> Is there a way to return just f1, f2, f3 in my results and forget revf3 (so
> it doesn't show in results)?

Sure just wrap it in a subselect:

select a.f1, a.f2, a.f3 from (select distinct on (revf3) f1, f2, f3,
revers(f3) as revf3 from table order by revf3) as a;

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Wes James 2012-12-21 18:50:39 Re: deciding on one of multiple results returned
Previous Message Wes James 2012-12-21 17:28:17 Re: deciding on one of multiple results returned