Re: Delete Question

From: Pandurangan R S <pandurangan(dot)r(dot)s(at)gmail(dot)com>
To: Alex <alex(at)meerkatsoft(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Delete Question
Date: 2005-12-07 07:55:18
Message-ID: 5e744e3d0512062355w2f059624v33ef967b858527fe@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)meerkatsoft(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2005-12-07 08:02:02 Re: Delete Question
Previous Message A.j. Langereis 2005-12-07 07:54:56 Re: Delete Question