Re: COPY from .csv File and Remove Duplicates

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: COPY from .csv File and Remove Duplicates
Дата
Msg-id 6CA55C4C-D5C4-43DE-9B35-99C2D6622E4D@yahoo.com
обсуждение исходный текст
Ответ на Re: COPY from .csv File and Remove Duplicates  (Rich Shepard <rshepard@appl-ecosys.com>)
Ответы Re: COPY from .csv File and Remove Duplicates
Re: COPY from .csv File and Remove Duplicates
Список pgsql-general
>  A pointer to the appropriate syntax for retrieving the entire row when
> count(loc_name, sample_date, param) > 1 would be much appreciated.
>
> Rich
>

Select *
From table
Natural Inner join (
SELECT loc_name, sample_date, param, Count(*) as duplicate_count
FROM table
Group by loc_name, sample_date, param
) grouped
Where duplicate_count > 1
;

You first group and count on the candidate key and then effectively self-joint that result back onto the original
table. natural join is short-hand for cases where the two joining table use the same name for semantically identical
field. Much easier than saying "t1.field1 = t2.field1 AND t1.field2 = t2.field2 AND etc..." 

David J.

В списке pgsql-general по дате отправления: