select dates,sum(number) total
from
(
select dates,sums as number
from Table1
union all
select dates,alls as number
from Table2
union all
select dates,price as number
from Table3
) t
group by dates
$result = DB::select("
select
dates,
sum(number) total
from
(
select
dates,
sums as number
from
Table1
union all
select
dates,
alls as number
from
Table2
union all
select
dates,
price as number
from
Table3
) t
group by
dates
");
$sql = <<<SQL
select dates,sum(number) total
from
(
select dates,sums as number
from Table1
union all
select dates,alls as number
from Table2
union all
select dates,price as number
from Table3
) t
group by dates
SQL;