Re: difference when using 'distinct on'

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
Cc: "pg-general (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: difference when using 'distinct on'
Date: 2003-09-12 16:07:14
Message-ID: 20030912160714.GA5956@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Sep 12, 2003 at 09:29:39 -0400,
"Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com> wrote:
>
> In the first example, is it just getting
> the unique rows for the first two columns?

Yes. Normally you would use distinct on in combination with an order by
so that you get the particular unique row you are interested in.
For example if col1 and col2 were an event type and col3 was a timestamp
for the event, you could use distinct on to get the earliest or latest
timestamp for each event type.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Manfred Koizar 2003-09-12 16:07:53 Re: State of Beta 2
Previous Message scott.marlowe 2003-09-12 15:59:59 Re: Function to convert