I have two tables
Table_1:
╔══════╦══════════╦═════════╗
║ Name ║ Date ║ Revenue ║
╠══════╬══════════╬═════════╣
║ A ║ 1/1/2001 ║ 20 ║
║ A ║ 1/2/2001 ║ 20 ║
║ B ║ 1/1/2001 ║ 40 ║
╚══════╩══════════╩═════════╝
Table_2:
╔══════╦══════╗
║ Name ║ Task ║
╠══════╬══════╣
║ A ║ Call ║
║ A ║ Foo ║
║ B ║ Bar ║
╚══════╩══════╝
So I do a join
SELECT sum(Revenue), t2.Name, T2.Task
FROM Table_1 as t1 JOIN Table_2 as t2 ON t1.Name = t2.Name
GROUP BY t2.Name
The result table of the join looks like this:
Result
Name Sum
A 80
B 40
The problem is that I want the sum result of A to be 40. How should I modify my query?