Re: Select duplicated values

Поиск
Список
Период
Сортировка
От Edson Richter
Тема Re: Select duplicated values
Дата
Msg-id 4ECAD7CB.6030503@simkorp.com.br
обсуждение исходный текст
Ответ на Select duplicated values  (jeffrey <johjeffrey@hotmail.com>)
Список pgsql-general
I think you should not "add columns", but concatenate them.

Instead

select A from table_name where B+C+D in (select B+C+D from table_name
group by B+C+D having count(*)>1  )

use "B || '/' || C || '/' || D"

select A from table_name where B || '/' || C || '/' || D in (select B || '/' || C || '/' || D from table_name
group by 1 having count(*)>1  )

You may need to apply some conversion (cast) depending of data type and output format.

Regards,

Edson Carlos Ericksson Richter
SimKorp Informática Ltda
Fone:(51) 3366-7964
Celular:(51)9318-9766/(51) 8585-0796
Embedded Image


Em 21-11-2011 20:23, jeffrey escreveu:
Lets say that the primary key column is A.  I am trying to select all
the rows with duplicated values in columns B, C, and D.

I am not too experienced in SQL syntax, and I've used the following:
select A from table_name where B+C+D in (select B+C+D from table_name
group by B+C+D having count(*)>1  )

I'm looking for a better way, since I am just adding the three columns
together right now.

Jeffrey

Вложения

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

Предыдущее
От:
Дата:
Сообщение: successive select statements
Следующее
От: Pete Yunker
Дата:
Сообщение: Re: Select duplicated values