我加入3个表Opportunity
,Lead
,Notes
如何内摆脱重复的加入在SQL Server
Select
Distinct O.oppo_jobid, O.oppo_status,
cast(N.Note_Note as NCHAR) as Notes
from Opportunity O, Notes N
Inner join Notes on o.Oppo_OpportunityId = Notes.Note_ForeignId
Inner join Lead on o.Oppo_OpportunityId = Lead.Lead_OpportunityID
我得到重复。如何在使用内部连接时避免重复?
主要表为Opportunity
和Notes
与opportunity id
进行了比较和Notes
表在如此重复出现同样的机会多条记录。现在,我怎样才能避免重复,同时比较表和获取最后更新的笔记。
在此先感谢...
你施放表达'投(N.Note_Note as NCHAR)'会返回一个固定的30个字符长度的列,这绝对是期望的结果吗?加入“铅”的目的是什么? –
[this one](http://stackoverflow.com/questions/13534939/duplicated-results-when-performing-inner-join)也很容易理解。 – Sohail