From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | Josué Maldonado <josue(at)lamundial(dot)hn> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Select groupping by one column |
Date: | 2003-12-18 21:25:18 |
Message-ID: | 20031218212518.GB28777@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Dec 18, 2003 at 15:09:52 -0800,
Josué Maldonado <josue(at)lamundial(dot)hn> wrote:
> Hello list,
>
> I have a table called pedh that looks like this:
>
> REFNO FECHA OCNUM PVD
> 0199 10/12/2003 5224 632
> 0199 10/12/2003 5224 632
> 1264 10/18/2003 8991 210
> 1264 10/18/2003 8991 210
> 1264 10/18/2003 8991 210
> 9093 10/20/2003 6895 520
> 9093 10/20/2003 6895 520
>
> I need to select one record groupped by column refno, I tried using this
> code:
>
> select refno, max(fecha), max(ocnum), max(pvd) from pedh
I don't see how that could work. Maybe you left off group by. But if you
did the aggreates could come from different rows, which might not be what
you want.
>
> It seems to work fine, but is there another way to get the same result
> avoing use of aggregate functions?
You might be able to use distinct on instead of aggregates.
From | Date | Subject | |
---|---|---|---|
Next Message | Andrei Ivanov | 2003-12-18 21:28:48 | Re: How to navigate tree without CONNECT BY? |
Previous Message | Andrew Sullivan | 2003-12-18 21:24:00 | Re: Replication |