Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 19D4E475DA7 for ; Thu, 12 Sep 2002 22:25:27 -0400 (EDT) Received: from water.oasis.net.au (water.oasis.net.au [210.8.139.2]) by postgresql.org (Postfix) with ESMTP id A136F475AE5 for ; Thu, 12 Sep 2002 22:25:25 -0400 (EDT) Received: from oasis.net.au (guardian [210.8.139.5]) by water.oasis.net.au (8.9.3/100.1) with ESMTP id MAA11320 for ; Fri, 13 Sep 2002 12:49:48 +1000 X-Authentication-Warning: water.oasis.net.au: Host guardian [210.8.139.5] claimed to be oasis.net.au Message-ID: <3D814DEB.6090807@oasis.net.au> Date: Fri, 13 Sep 2002 12:31:07 +1000 From: Rudi Starcevic User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: DISTINCT Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/123 X-Sequence-Number: 9400 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