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!

duplicates in sql query out put when qury has join on multiple tables.

956118Feb 28 2013 — edited Feb 28 2013
I have the below query whcih is returning 2 duplicate records.

Is there any way how to figure out from which table is causing the duplicate?

There are so many inline view and join conditions in this query .

in waht join conditions i need to look into mainly?

or how to find the whcih table is causing the duplicate when we have multimple joins?

this is really bothering me a lot .please help me with this.




SELECT       'BCCALGLB'            model_cd,
                     fi_instrument_id,
                     fmr_cusip             instrument_id,
                     price,
                     '27-FEB-2013'          pricing_dt,
                     currency_cd 
                     FROM         (SELECT  II.fmr_cusip,
                              IAI.fi_instrument_id,
                              IP.price,
                              IP.currency_cd
                      FROM    (SELECT  IdxHldg.vendor_instrument_id,
                                       IdxHldg.index_cd,
                                       IdxHldg.data_source_cd,
                                       GM.member_rank,
                                       RANK () OVER (PARTITION BY  IdxHldg.vendor_instrument_id
                                                     ORDER BY      GM.member_rank  ASC)  priority
                               FROM    (SELECT  IBH.vendor_instrument_id,
                                                IBH.index_cd,
                                                IBH.data_source_cd
                                        FROM    fi_idx_benchmark_holdings  IBH
                                        WHERE   IBH.pricing_dt = '27-FEB-2013'

                                        UNION

                                        SELECT  IFH.vendor_instrument_id,
                                                IFH.index_cd,
                                                IFH.data_source_cd
                                        FROM    fi_idx_forward_holdings  IFH
                                        WHERE   IFH.pricing_dt = '27-FEB-2013'
                                       )  IdxHldg,
                                       fi_group_member  GM
                               
                               WHERE   GM.group_cd      = 'BCGLOBALIDX'
                               AND     GM.purpose_cd    = 'GLOBALIDX'
                               AND     IdxHldg.index_cd = GM.character_val
                              )  BCIdxHldg,
                              fi_idx_instrument  II,
                              fi_idx_price  IP,
                              instrument_alternate_id  IAI,
                              instrument  I
                      WHERE   BCIdxHldg.priority                  =      1
                      AND     BCIdxHldg.data_source_cd            =      II.data_source_cd
                      AND     BCIdxHldg.vendor_instrument_id      =      II.vendor_instrument_id
                      AND     II.data_source_cd                   =      IP.data_source_cd
                      AND     II.vendor_instrument_id             =      IP.vendor_instrument_id
                      AND     IP.currency_cd                      =      I.currency_cd
                      AND     IP.pricing_dt                       =      '27-FEB-2013'
                      AND     II.fmr_cusip                        =      IAI.alternate_id
                      AND     IAI.alternate_id_type_code          =      'FMR_CUSIP'
                      AND     IAI.fi_instrument_id                =      I.fi_instrument_id
                      AND     NVL (I.instrument_domain_cd, 'XXX') NOT IN ('MBS', 'MGEN')
                      AND     NVL (I.instrument_type_cd, 'XXX')   !=     'CMBS'

                      AND     ((I.currency_cd                     NOT IN ('CAD', 'USD'))
                               OR
                               (EXISTS (SELECT  1
                                        FROM    adm_calendar_date  ACD,
                                                ctry_curr_link  CCL
                                        WHERE   TO_DATE (ACD.calendar_yyyymmdd, 'YYYYMMDD') = '27-FEB-2013'
                                        AND     ACD.calendar_origin_cd                      = 'EXCHANGE'
                                        AND     ACD.calendar_type_cd                        = 'BUSINESS'
                                        AND     ACD.geography_cd                            = CCL.ctry_cd
                                        AND     CCL.link_typ                                = 'ISS'
                                        AND     CCL.curr_cd                                 = I.currency_cd
                                        AND     ACD.business_day_ind                        = 'Y'))))
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 28 2013
Added on Feb 28 2013
1 comment
169 views