title: Case statement in Join Clause
body: <p>I am trying to get data from multiple tables but not sure how to do that. Below is a query which I am using but its not working. Please suggest.</p>
  
  <pre><code>SELECT DISTINCT 
          VWL.Type, VWL.ID AS CompanyID,VWL.Name
      FROM dbo.LeadList_New AS VWL 
      LEFT OUTER JOIN
          CASE VWL.Type WHEN 'COMPANY' THEN
              CRMCompanyEmailAddress AS CE ON VWL.ID=CE.CRMCompanyID
          WHEN 'PERSON' THEN
              PersonEmailAddress AS PE ON VWL.ID=PE.PersonID
          END
  </code></pre>