B
B
Bogdan2017-09-29 17:16:57
PostgreSQL
Bogdan, 2017-09-29 17:16:57

Duplicate selection?

Hello. What is the best way to display duplicate records, maybe there are regular tools in PostgreSQL?
And which of my two options is preferable? Provided that result of sampling of 200 records, and records more than 1000 (in other tables there can be other variants)? But how would the question about regular means of such a sample be more interesting? thank.

-- Вариант 1
select * from children_groups aa
where code in (select code from children_groups group by code having count(*)>1)
order by code;

-- Вариант 2
select bb.* 
  from (select code from children_groups group by code having count(*)>1) aa
left join children_groups bb on aa.code = bb.code
order by bb.code;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question