Re: [GENERAL] Delete Question

2005-12-07 Thread A. Kretschmer
am 07.12.2005, um 8:54:56 +0100 mailte A.j. Langereis folgendes: > Postgresql supports records in the where clause i.e. you can compare > multiple columns simultaneously: > > > test=# delete from change where id || ':' || datum not in (select id || > ':' || max(datum) from change group by id ord

Re: [GENERAL] Delete Question

2005-12-06 Thread A.j. Langereis
e from change where (id, datum) in (select id, max(datum) from change group by id); Yours, Aarjan Langereis - Original Message - From: "A. Kretschmer" <[EMAIL PROTECTED]> To: Sent: Wednesday, December 07, 2005 8:47 AM Subject: Re: [GENERAL] Delete Question > am

Re: [GENERAL] Delete Question

2005-12-06 Thread Pandurangan R S
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 <[EMAIL PROTECTED]> wrote: > Hi, > > I have a table where I store changes made to an order. The looks like > ProdID, ChangeDate, Change1, Change2, ...

Re: [GENERAL] Delete Question

2005-12-06 Thread Alex
Thanks , this one works beautifully. Alex PS: also thanks to the other suggestions, have a look at this one hubert depesz lubaczewski wrote: On 12/7/05, *Alex* <[EMAIL PROTECTED] > wrote: I have a table where I store changes made to an order. The looks like

Re: [GENERAL] Delete Question

2005-12-06 Thread A. Kretschmer
am 07.12.2005, um 18:21:25 +1100 mailte Alex folgendes: > 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 mos

Re: [GENERAL] Delete Question

2005-12-06 Thread Michael Glaesemann
On Dec 7, 2005, at 16:21 , Alex wrote: 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? Here's one way to do it, though not it one SQL statement: create table copy_of_original_table as select dist

Re: [GENERAL] Delete Question

2005-12-06 Thread hubert depesz lubaczewski
On 12/7/05, Alex <[EMAIL PROTECTED]> wrote: I have a table where I store changes made to an order. The looks likeProdID, 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) o