pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rudi Starcevic <rudi@oasis.net.au>
To: pgsql-sql@postgresql.org
Subject: DISTINCT
Date: Fri, 13 Sep 2002 12:31:07 +1000
Message-ID: <3D814DEB.6090807@oasis.net.au> (raw)

Hello,

I'd like to select from one table ( contains duplicates ) into a new table.
However the new table is exactly the same as the original ( duplicates 
included )
I think I have a problem with my DISTINCT clause - sql below.

It seems the DISTINCT is applied to the whole row not just the 'phone' 
field.
Is the a way I can select the whole row into a new table based on a DISTINCT
phone number ?

Is the a way I can select the whole row into a new table based on a DISTINCT
phone number and state ?


Else I'll need to select into a table then select again etc,etc ....to 
remove duplicates.

SELECT
    DISTINCT phone,
    company_name,
    address,
    state,
    idc_desc_1,
    street_number,
    street_name,
    street_xtra,
    suburb,
    postcode,
    area_code,
    ac_phone,
    fax_area_code,
    fax_phone,
    fax_ac_phone,
    latitude,
    longitude
INTO export_temp
FROM export;

Thanks
Rudi




view thread (4+ messages)  latest in thread

Message-ID: <3D814DEB.6090807@oasis.net.au>
Permalink:  ../3D814DEB.6090807@oasis.net.au/
Also on:    postgresql.org/message-id/3D814DEB.6090807@oasis.net.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rudi@oasis.net.au
  Subject: Re: DISTINCT
  In-Reply-To: <3D814DEB.6090807@oasis.net.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox