Home > Linux, PostgreSQL, Slackware > Linux : Slackware : PostgreSQL 8.3.7 find the duplicates in a table

Linux : Slackware : PostgreSQL 8.3.7 find the duplicates in a table

“PostgreSQL 8.3.7 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2″

ext_id should be unique, but its not, so to get all the records with duplicate ext_id :

select 
ext_id 
from dd_out dd 
where true 
and ext_id in 
(
  select ext_id  as ddd from (
    select count(s.ext_id) as cnt, s.ext_id from dd_out s where true group by s.ext_id 
  ) as cra  
  where cnt > 1 
)
;
About these ads
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: