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
обсуждение исходный текст
Ответ на Re: [personal] Re: Filtering duplicated row with a trigger  (papapep <papapep@gmx.net>)
Список pgsql-novice
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
Дата:
Сообщение: Re: [personal] Re: Filtering duplicated row with a trigger
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: [personal] Re: Filtering duplicated row with a trigger