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!

using UNION to select out duplicate records

15379Nov 7 2001
I have a question regarding the use of UNION. I am selecting
data from four schemas into one cursor C1. Between these
individual schemas there are duplicate records. As per the code
below I am able to select unique records and avoid duplicate
records in the Cursor. However, I am getting duplicate fields
within two or three records since UNION only eliminates
duplicate records. I really need to make sure I don't have
duplicate records and duplicate fields. I am putting this data
in a data warehouse and can't have duplicate fields or records.
Any advice is appreciated in advance.

Thanks
-Pat
PS: specifically I am getting duplicate pcode fields that have
unique pdesc, which in turn classify them as unique records.

CURSOR C1
IS
SELECT PCODE, PDESC FROM gpcomp1.gppcat
UNION
SELECT PCODE, PDESC FROM gpcomp2.gppcat
UNION
SELECT PCODE, PDESC FROM gpcomp3.gppcat
UNION
SELECT PCODE, PDESC FROM gpcomp4.gppcat;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 26 2001
Added on Nov 7 2001
16 comments
534 views