Re: Help with SQL staterment - Mailing list pgsql-novice

From Chris Campbell
Subject Re: Help with SQL staterment
Date
Msg-id 453A24085F801842AEA8D0B6B269065DD23DCC9846@HDMC.cds.local
Whole thread Raw
In response to Re: Help with SQL staterment  (Thom Brown <thom@linux.com>)
Responses problem  ("Phillip B Childs" <it@marisusa.com>)
List pgsql-novice
> On 06/30/2011 04:04 PM, Thom Brown wrote:
>>
>> SELECT DISTINCT ON (contactkey)
>>     paymentkey, contactkey, paymentdate
>> FROM
>>     my_table
>> ORDER BY
>>     contactkey, paymentdate DESC
>
> Gives the same result as my example but your solution is much cleaner.

I would have never thought that "SELECT DISTINCT ON" would return that result set, but amazingly it works like a charm.
Obviously I need to study up on that syntax. 

Many thanks for all the assistance.

Chris


pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: change data type 'money' to '€'
Next
From: "Phillip B Childs"
Date:
Subject: problem