Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

QueryExpression With Multiple Join Conditions

$
0
0

Hi,

I am trying to translate the following SQL query to a QueryExpression:

SELECT  a.AccountId, o.opportunityid
FROM    dbo.Account a
        INNER JOIN dbo.Opportunity o ON o.CustomerId = a.AccountId
        LEFT JOIN dbo.new_creditpackagefile cpf ON cpf.new_accountid = o.CustomerId
                                                             AND cpf.new_opportunityid = o.OpportunityId
                                                             AND cpf.new_documenttype = 32;


Here's how I would rewrite the above SQL to be possible via QueryExpression:

SELECT  DISTINCT a.AccountId, o.opportunityid
FROM    dbo.Account a
        INNER JOIN dbo.Opportunity o ON o.CustomerId = a.AccountId
        LEFT JOIN dbo.new_creditpackagefile cpf ON cpf.new_accountid = o.CustomerId AND cpf.new_documenttype = 32
	LEFT JOIN dbo.new_creditpackagefile cpf2 ON cpf2.new_opportunityid = o.OpportunityId AND cpf2.new_documenttype = 32


The downside of the second query is that it uses another left join and the DISTINCT operator. 

Questions:

  1. Do you think the additional join and DISTINCT operator would have a meaningful performance hit?
  2. Will there be support for multiple join conditions in the future?

Thank you very much!


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>