My structure is like this
table1 key value date
table2 key value date
table3 key value date
I would like to have a sql query which returns distinct all keys and the sum of all values for each key from all 3 tables.
My try has been
Select key=
(select table1.key from table1 where date = '2017-05-30' union
select table2.key from table2 where date = '2017-05-30' union
select table3.key from table3 where date = '2017-05-30'),
(select sum(value) from table1 where table1.key = key and date = '2017-05-30' ) +
select (sum(value) from table2 where table2.key = key and date = '2017-05-30') +
select (sum(value) from table3 where table3.key=key and date = '2017-05-30')
from table1, table2, table3