Thanks. I was testing different things and I came up with something
similar to that. I appreciate you taking time to answer.
On Fri, Dec 21, 2012 at 11:22 AM, Scott Marlowe wrote:
> On Fri, Dec 21, 2012 at 10:28 AM, Wes James wrote:
> > David and Seth Thanks. That helped.
> >
> >
> > When I
On Fri, Dec 21, 2012 at 10:28 AM, Wes James 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
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)?
Thanks.
On Fri, Dec 21, 2012 at 9:57 AM, Seth Gordon
If you only want one value per id, then your query should be “SELECT
DISTINCT ON (id) ...”
If you care about which particular value is returned for each ID, then you
have to sort the results: e.g., if you want the minimum value per id, your
query should be “SELECT DISTINCT ON (id) ... ORDER BY val
From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org]
On Behalf Of Wes James
Sent: Friday, December 21, 2012 11:32 AM
To: pgsql-sql@postgresql.org
Subject: [SQL] deciding on one of multiple results returned
If a query returns, say the following results:
id value
0
If a query returns, say the following results:
id value
0 a
0 b
0 c
1 a
1 b
How do I just choose a preferred element say value 'a' over any other
elements returned, that is the value returned is from a subquery to a
larger query?
Thanks.