Get only the first row for duplicate data
RanieriMay 31 2011 — edited May 31 2011Hello,
I have the following situation...
I have a table called employees with column (re, name, function) where "re" is the primary key.
I have to import data inside this table using an xml file, the problem is that some employees can be repeated inside this xml, that means, I'll have repeated "re"'s, and this columns is primary key of my table.
To workaround, I've created a table called employees_tmp that has the same structed as employees, but without the constraint of primary key, on this way I can import the xml data inside the table employees_tmp.
What I need now is copy the data from employees_tmp to employess, but for the cases where "re" is repeated, I just want to copy the first row found.
Just an example:
EMPLOYEES_TMP
---------------------
RE NAME FUNCTION
0987 GABRIEL ANALYST
0987 GABRIEL MANAGER
0978 RANIERI ANALYST
0875 RICHARD VICE-PRESIDENT
I want to copy the data to make employees looks like
EMPLOYEES
---------------------
RE NAME FUNCTION
0987 GABRIEL ANALYST
0978 RANIERI ANALYST
0875 RICHARD VICE-PRESIDENT
How could I do this?
I really appreciate any help.
Thanks