Reputation: 31
I have 2 tables
I'm trying to left join both the tables to get the sum total of amount along side volume/date.
Below is the query I'm trying, however getting very huge amount as result.
SELECT
PeriodDate, SUM(Volume), SUM(Amount)
FROM
Calls
LEFT JOIN
Amount ON Calls.PeriodDate = Amount.PeriodDate
GROUP BY
PeriodDate
Upvotes: 0
Views: 79
Reputation: 48850
You can do:
select a.*, b.amount
from (
select perioddate, sum(volume) as volume from calls group by perioddate
) a
left join (
select perioddate, sum(amount) as amount from amount group by perioddate
) b on b.perioddate = a.perioddate
Upvotes: 1