Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9002389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:33:51+00:00 2026-06-16T00:33:51+00:00

I have two tables that I would like to join with the following columns:

  • 0

I have two tables that I would like to join with the following columns:

Tables: #IndexDecomposition; Constituent.

Rows: Identifier; CUSIP; ISIN; SEDOL.

This is all part of a larger MERGE statement, and now I think that the cross join is happening on the INSERT statement:

MERGE indexdecomp.ConstituentWeighting targ
USING (#IndexConstituents src
       INNER JOIN indexDecomp.Constituent c WITH (NOLOCK) on 
        ((c.Identifier = src.Identifier) OR (c.Identifier IS NULL AND src.Identifier IS NULL))
           AND ((c.CUSIP = src.CUSIP) OR (c.CUSIP IS NULL AND src.CUSIP IS NULL))
           AND ((c.ISIN = src.ISIN) OR (c.ISIN IS NULL AND src.ISIN IS NULL))
           AND ((c.SEDOL = src.SEDOL) OR (c.SEDOL IS NULL AND src.SEDOL IS NULL)))
ON (    targ.ConstituentId = c.Id 
    AND targ.AsOfDate = src.Date
    AND ((targ.Weighting = src.Weighting) OR (targ.Weighting IS NULL AND src.Weighting IS NULL))
    AND ((targ.TotalSharesHeld = src.TotalSharesHeld) OR (targ.TotalSharesHeld IS NULL AND src.TotalSharesHeld IS NULL))
    AND ((targ.SharesOutstanding = src.SharesOutstanding) OR (targ.SharesOutstanding IS NULL AND src.SharesOutstanding IS NULL))
    AND ((targ.NotionalValue = src.NotionalValue) OR (targ.NotionalValue IS NULL AND src.NotionalValue IS NULL))
    AND ((targ.MarketValue = src.MarketValue) OR (targ.MarketValue IS NULL AND src.MarketValue IS NULL))
    AND ((targ.MarketCap = src.MarketCap) OR (targ.MarketCap IS NULL AND src.MarketCap IS NULL))
    AND ((targ.LastTrade = src.LastTrade) OR (targ.LastTrade IS NULL AND src.LastTrade IS NULL))
    AND ((targ.Earnings = src.Earnings) OR (targ.Earnings IS NULL AND src.Earnings IS NULL))
    AND ((targ.PeRatio = src.PeRatio) OR (targ.PeRatio IS NULL AND src.PeRatio IS NULL))
    AND ((targ.Face = src.Face) OR (targ.Face IS NULL AND src.Face IS NULL)))
WHEN NOT MATCHED BY TARGET THEN
    INSERT (
         ConstituentID
        ,AsOfDate
        ,Weighting
        ,TotalSharesHeld
        ,SharesOutstanding
        ,NotionalValue
        ,MarketValue
        ,MarketCap
        ,LastTrade
        ,Earnings
        ,PeRatio
        ,Face
        ,ModifiedBy
        ,ModifiedDate
        ,CreatedBy
        ,CreatedDate
    )
    VALUES (
         c.Id
        ,src.Date
        ,src.Weighting
        ,src.TotalSharesHeld
        ,src.SharesOutstanding
        ,src.NotionalValue
        ,src.MarketValue
        ,src.MarketCap
        ,src.LastTrade
        ,src.Earnings
        ,src.PeRatio
        ,src.Face
        ,'user'
        ,getdate()
        ,'user'
        ,getdate()
    )
;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:33:52+00:00Added an answer on June 16, 2026 at 12:33 am

    I think the only problem with your latest attempt is that it does not weed out combinations of all nulls (i.e. false positives where all four IDs are null). You can fix it by requiring that at least one of the four identifiers mus be non-null, like this:

    SELECT *
    FROM xTradeCapture.staging.IndexDecomposition src
    INNER JOIN indexDecomp.Constituent c WITH (NOLOCK) on 
    (((c.Identifier = src.Identifier) OR (c.Identifier IS NULL AND src.Identifier IS NULL))
    AND ((c.CUSIP = src.CUSIP) OR (c.CUSIP IS NULL AND src.CUSIP IS NULL))
    AND ((c.ISIN = src.ISIN) OR (c.ISIN IS NULL AND src.ISIN IS NULL))
    AND ((c.SEDOL = src.SEDOL) OR (c.SEDOL IS NULL AND src.SEDOL IS NULL))
    AND (c.Identifier IS NOT NULL OR c.CUSIP IS NOT NULL OR c.ISIN IS NOT NULL OR c.SEDOL IS NOT NULL))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that will join two different tables together and provide
I have the following linq expression that lets me join two tables, group them
I was thinking that I would have two tables for mysql. One for storing
I have two tables that I want to join together. Table1 Year, ID, Theme,
I have two tables that I am joining with the following query... select *
Let's say I have two tables that look like this: TH TH TH TH
I have two tables (tbArea, tbPost) that relate to the following classes. class Area
I have three tables I would like to join to pull off a MySQL
I have two tables in MySQL that I'm comparing with the following attributes: tbl_fac
We have three tables that we would like to query to find out the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.