MySQL sum two values different tables -
first of all, excuse me may have seen question before, i've tried solutions around here. it's not matching need. have 2 tables. 1 of them sales section agents, other technical support agents. need sum values of received calls in both sections per day.
my table structure , sample data:
example : date column remain is, received column = sales.received + tech.received , sales.answered + tech.answered came through :
select (select sum(`received_calls`) sales) + (select sum(`received_calls`) tech ) dual
but it's showing total only.. without showing daily calculation every day.
expected outcome:
--------------------------------------------- date | received | answered | abandoned --------------------------------------------- |2014-11-14| 8406 | 8363 | 43 |2014-11-15| 9909 | 9792 | 116 ---------------------------------------------
and there no dates available on table without other, every day's date available on both tables no exceptions.
any help? :)
assuming dates unique (per table), can join according , add appropriate values:
select s.`date`, s.received_calls + t.received_calls received, s.answered_calls + t.answered_calls answered, s.abandoned_calls + t.abandoned_calls abandoned sales s join tech t on s.`date` = t.`date`
Comments
Post a Comment