By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table receita_1 (id int AUTO_INCREMENT not NULL PRIMARY KEY , valor NUMERIC(15,2), data date);
create table receita_2 (id int AUTO_INCREMENT not NULL PRIMARY KEY , valor NUMERIC(15,2), data date);
insert into receita_1 (data, valor) VALUES ('2018-01-01',100);
insert into receita_1 (data, valor) VALUES ('2018-01-02',200);
insert into receita_1 (data, valor) VALUES ('2018-01-03',300);
insert into receita_1 (data, valor) VALUES ('2018-01-04',400);
insert into receita_1 (data, valor) VALUES ('2018-01-05',500);
insert into receita_1 (data, valor) VALUES ('2018-01-06',600);
insert into receita_2 (data, valor) VALUES ('2018-01-01',1000);
insert into receita_2 (data, valor) VALUES ('2018-01-02',2000);
insert into receita_2 (data, valor) VALUES ('2018-01-03',3000);
insert into receita_2 (data, valor) VALUES ('2018-01-04',4000);
insert into receita_2 (data, valor) VALUES ('2018-01-05',5000);
insert into receita_2 (data, valor) VALUES ('2018-01-06',6000);
select sum(valor) from (
select * from receita_1
union all
select * from receita_2
)ff
where data BETWEEN '2018-01-01' and '2018-01-04'
sum(valor) |
---|
11000.00 |