Re: [personal] Re: Filtering duplicated row with a trigger

Поиск
Список
Период
Сортировка
Искать
От
Nabil Sayegh
Тема
Re: [personal] Re: Filtering duplicated row with a trigger
Дата
Msg-id
3F81A3ED.8000705@e-trolley.de
Ответ на
Список
Дерево обсуждения
Filtering duplicated row with a trigger papapep <papapep@gmx.net>
Re: Filtering duplicated row with a trigger Bruno Wolff III <bruno@wolff.to>
Re: [personal] Re: Filtering duplicated row with a trigger papapep <papapep@gmx.net>
Re: [personal] Re: Filtering duplicated row with a trigger Josh Berkus <josh@agliodbs.com>
Re: [personal] Re: Filtering duplicated row with a trigger papapep <papapep@gmx.net>
Re: [personal] Re: Filtering duplicated row with a trigger Bruno Wolff III <bruno@wolff.to>
Re: [personal] Re: Filtering duplicated row with a trigger papapep <papapep@gmx.net>
Re: [personal] Re: Filtering duplicated row with a trigger Josh Berkus <josh@agliodbs.com>
Re: [personal] Re: Filtering duplicated row with a trigger Bruno Wolff III <bruno@wolff.to>
Re: [personal] Re: Filtering duplicated row with a trigger Nabil Sayegh <postgresql@e-trolley.de>
Re: Filtering duplicated row with a trigger Nabil Sayegh <postgresql@e-trolley.de>
papapep wrote:
> If so, how should I do
> the duplicates control in the temp table? (for me is as difficult as my
> first question :-( )
> Consider that the primary key that we use to see if the row is
> duplicated, or not, is a 5 fields key (it has to be so, is a complex
> data to filter).

CREATE TEMP TABLE tempo (a int, b int, c text);
INSERT INTO tempo (a,b,c) values (1,1,'foo');
INSERT INTO tempo (a,b,c) values (1,2,'bar');
INSERT INTO tempo (a,b,c) values (1,1,'foo');
INSERT INTO tempo (a,b,c) values (1,1,'foo');
INSERT INTO tempo (a,b,c) values (1,1,'foo-bar');

SELECT distinct on (a,b) a, b, c from tempo;
  a | b |  c
---+---+-----
  1 | 1 | foo
  1 | 2 | bar
(2 Zeilen)

This DISTINCT ON select only cares for the given arguments (a,b) to be 
distinct. Which c is returned is undefined (random).

HTH
-- 
  e-Trolley Sayegh & John, Nabil Sayegh
  Tel.: 0700 etrolley /// 0700 38765539
  Fax.: +49 69 8299381-8
  PGP : http://www.e-trolley.de

В списке pgsql-novice по дате отправления
От: Josh Berkus
Дата:
От: Bruno Wolff III
Дата:
FAQ