表 tblCountResults
**Columns**
Activity
MinOfName
CountOfActivity
表 tblCountResultsSQL
**Columns**
Activity
MinOfName
CountOfActivity
我需要的是将这两个表合并为一个。如果活动匹配,我需要将两个表中的CountofActivity添加到一起。无论是否匹配,我都需要保留Activity和MinOfName。
答案 0 :(得分:0)
也许是这样,但我不确定如果MinofName的多个属于同一个活动,将会如何处理......
Select coalesce(A.activity, B.Activity) as Activity,
coalesce(A.MinofName, B.MinofName) as MinOfName,
coalesce(A.countofActivity,0) + coalesce(b.CountofActivity) as SumofcountofActivty
FROM tblCountResults A Full outer Join tblCountResultsSQL B
ON A.Activity = B.Activity
答案 1 :(得分:0)
select isnull(t1.activity, t2.activity) as activity,
isnull(t1.MinOfName, t2.MinOfName) as MinOfName,
isnull(t1.CountOfActivity, 0) + isnull(t2.CountOfActivity, 0) as count
from tblCountResults t1
full outer join tblCountResultsSQL t2 on t2.activity = t2.activity