0

enter image description here

I want to find SUM of Table 1 & Table 2 in Result Table. As shown in the above Result table.

I have tried with the query below

Select
  Sum(t2.[Lead Score] + t1.[Lead Score]) [Lead Score],
  t2.SubscriberKey
from [Table1] t2
left join [Table2]  t1
  on t2.SubscriberKey= t1.SubscriberKey
group by t2.SubscriberKey

enter image description here

  • If my answer helped, please mark it as accepted so others can easily see this has been resolved. Thank you! – Markus Slabina Sep 9 '17 at 9:51
2

You could build the sum of a subquery that combines the results of two tables using UNION.

SELECT
  r.SubscriberKey [SubscriberKey],
  sum(r.[Lead Score]) [Lead Score]
FROM
  (
    SELECT
      SubscriberKey,
      [Lead Score]
    FROM
      Table1
    UNION ALL
    SELECT
      SubscriberKey,
      [Lead Score]
    FROM
      Table2
  ) as r
GROUP BY SubscriberKey

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.