I have the following tables:

Table click and send

In the third table I want to combine these data with the SUM option in SQL so the total of clicks and Sends are in one field. Like this:

Output table

I created the following query:

SUM(s.Sends) as [Sends],
SUM(c.Click) as [Click],
FROM [Plus Tracking Journey Bounce] s
join [Plus Tracking Journey Click] c
on s.JourneyName = c.JourneyName
GROUP BY s.JourneyName, c.JourneyName

As a result I got this:

OUtput table2

It multiplies with 2 because there are two records in each table. I tried a different join but with no results. Is this even possible and if so, what do I miss.

1 Answer 1


Try this one:

select a.JourneyName
, sum(a.Click) as clicks
, sum(b.Sends) as sends
, sum(Click) as Click
from [Plus Tracking Journey Click]
group by JourneyName
) a
inner join 
, sum(Sends) as Sends
from [Plus Tracking Journey Bounce]
group by JourneyName
) b
on a.JourneyName = b.JourneyName
Group by a.JourneyName
  • 3
    If you were to put a little explanation into it instead of just the code, it is more likely to be an accepted answer and to get upvotes. Code only answers do not help people learn what the solution is, only provides them an answer. Think of it as 'You can give a man a fish and feed him for a day or teach a man to fish and feed him for life.' Commented Apr 8, 2021 at 14:06
  • Great, this works perfectly. Thank you!
    – Martijn e
    Commented Apr 8, 2021 at 14:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .