Re: Delete Question - Mailing list pgsql-general

From Pandurangan R S
Subject Re: Delete Question
Date
Msg-id 5e744e3d0512062355w2f059624v33ef967b858527fe@mail.gmail.com
Whole thread Raw
In response to Delete Question  (Alex <alex@meerkatsoft.com>)
List pgsql-general
DELECT FROM table
WHERE (ProdID,ChangeDate) not in
(SELECT ProdID,MAX(ChangeDate) FROM table
 GROUP BY ProdID)

I hope this works.

On 12/7/05, Alex <alex@meerkatsoft.com> wrote:
> Hi,
>
> I have a table where I store changes made to an order. The looks like
> ProdID, ChangeDate, Change1, Change2, ... etc.
> Some ProdIDs have multiple records.
>
> Is there an easy way to delete all records of a ProdID except the most
> recent (ChangeDate is timestamp) one? Preferably in one SQL statement?
>
> Thanks for any advise
>
> Alex
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>


--
Regards
Pandu

pgsql-general by date:

Previous
From: Alex
Date:
Subject: Re: Delete Question
Next
From: "A.j. Langereis"
Date:
Subject: Re: Delete Question