Re: Select Question
От | Jeff Eckermann |
---|---|
Тема | Re: Select Question |
Дата | |
Msg-id | 20040202193842.98284.qmail@web20806.mail.yahoo.com обсуждение исходный текст |
Ответ на | Re: Select Question (Martijn van Oosterhout <kleptog@svana.org>) |
Ответы |
Re: Select Question
|
Список | pgsql-general |
--- Martijn van Oosterhout <kleptog@svana.org> wrote: > See DISTINCT ON() Yes, for selecting. For deleting, probably something like: delete from table t1 where exists (select 1 from table t2 where t2.code = t1.code and t2.date > t1.date); You could write that as a join also. I have found little or no performance difference in the cases that I have tested, although you may find otherwise. BTW, I hope you are not really using "date" as a column name. That is too much trouble to be worth it. > > On Tue, Feb 03, 2004 at 12:22:29AM +0900, Alex > wrote: > > Hi, > > I need to remove duplicate records from a table > like > > > > Code Date > > XS111111 2004-01-26 > > XS111111 2003-01-22 > > XS222222 2004-02-01 > > XS222222 2004-01-26 > > XS222222 2003-01-22 > > > > where only the newest record of Code XSxxxxxxx is > kept in the table. Is > > there an easy way to do that? > > -- > Martijn van Oosterhout <kleptog@svana.org> > http://svana.org/kleptog/ > > (... have gone from d-i being barely usable even > by its developers > > anywhere, to being about 20% done. Sweet. And the > last 80% usually takes > > 20% of the time, too, right?) -- Anthony Towns, > debian-devel-announce > > ATTACHMENT part 2 application/pgp-signature __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/
В списке pgsql-general по дате отправления: