我正在尝试从多个表中获取数据,但不知道该怎么做。下面是我正在使用但它不起作用的查询。请建议。
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