Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Get only the first row for duplicate data

RanieriMay 31 2011 — edited May 31 2011
Hello,

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
This post has been answered by Ganesh Srivatsav on May 31 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 28 2011
Added on May 31 2011
1 comment
965 views