Re: simple problem???

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: marchesini(at)unipg(dot)it, pgsql-sql(at)postgresql(dot)org
Subject: Re: simple problem???
Date: 2006-07-20 20:47:52
Message-ID: 20060720204752.51889.qmail@web31813.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> A|B|C
> 1|2|20
> 1|3|10
> 1|4|21
> 2|3|12
> 2|4|22
> 3|4|23
> 1|3|10
> 2|3|12
> 3|4|23
> -select all records where A=1,
> -find, into this selection, the record where there's the minimum value
> of the field C
> -print all the fields for this record.

maybe this will work;

select a,b,c
from table as T1
join (select a, min(c) as minc from table group by a) as T2
on (t1.a = t2.a) and (t1.c = t2.c)
;

Regards,

Richard Broersma Jr.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2006-07-20 22:08:58 Re: Help with privilages please
Previous Message George Weaver 2006-07-20 20:45:34 Re: Error when trying to use a FOR loop