From: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: COPY from .csv File and Remove Duplicates |
Date: | 2011-08-12 18:03:15 |
Message-ID: | alpine.LNX.2.00.1108121100410.25454@salmo.appl-ecosys.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 12 Aug 2011, David Johnston wrote:
> Select *
> From table
> Natural Inner join (
> SELECT loc_name, sample_date, param, Count(*) as duplicate_count
> FROM table
> Group by loc_name, sample_date, param
> ) grouped
> Where duplicate_count > 1;
Tried to use the above in an INSERT INTO statement to a copy of the main
data table. Here's what I've tried and how postgres responds:
INSERT INTO chem_too
(lab_nbr, loc_name, sample_date, param, quant, units, qa_qc,
easting, northing, remark)
SELECT *
FROM chemistry
Natural Inner join (
SELECT loc_name, sample_date, param, Count(*) as duplicate_count
FROM chemistry
GROUP BY loc_name, sample_date, param) grouped
WHERE duplicate_count > 1;
psql -f cp_dups.sql nevada
psql:cp_dups.sql:10: ERROR: INSERT has more expressions than target columns
LINE 4: SELECT *
^
The INSERT INTO clause lists all columns in both tables so I fail to
understand to what the error message refers.
Rich
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2011-08-12 18:17:16 | Re: Functions returning setof record -- can I use a table type as my return type hint? |
Previous Message | George MacKerron | 2011-08-12 17:01:23 | Re: Functions returning setof record -- can I use a table type as my return type hint? |