Re: How to delete the not DISTINCT ON entries

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to delete the not DISTINCT ON entries
Date: 2004-06-16 12:18:26
Message-ID: Pine.LNX.4.44.0406161511460.2590-100000@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general pgsql-sql

O kyrios Christoph Haller egrapse stis Jun 16, 2004 :

> Referring to the DISTINCT ON example
>
> SELECT DISTINCT ON (location) location, time, report
> FROM weatherReports
> ORDER BY location, time DESC;

maybe smth like

delete from weatherReports where (location,time,report) not in
(SELECT DISTINCT ON (location) location, time, report FROM weatherReports
ORDER BY location, time DESC)

Note:
Order by is very important, since it affects which rows are deleted.

>
> How would I delete those entries skipped by the DISTINCT ON expression?
>
> TIA
>
> Regards, Christoph
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>

--
-Achilleus

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jean-Luc Lachance 2004-06-16 14:14:14 Re: How to delete the not DISTINCT ON entries
Previous Message Christoph Haller 2004-06-16 11:52:57 How to delete the not DISTINCT ON entries

Browse pgsql-general by date

  From Date Subject
Next Message Jernej Kos 2004-06-16 13:39:35 Re: Multicolumn indexes and ORDER BY
Previous Message Christoph Haller 2004-06-16 11:52:57 How to delete the not DISTINCT ON entries

Browse pgsql-sql by date

  From Date Subject
Next Message Jean-Luc Lachance 2004-06-16 14:14:14 Re: How to delete the not DISTINCT ON entries
Previous Message Christoph Haller 2004-06-16 11:52:57 How to delete the not DISTINCT ON entries