clear markdown compare help donate or buy diddy dollings comments/suggestions/bugs a leap of faith? bible365
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 818513 fiddles created (9187 in the last week).

create table tbl1 ( name varchar(20), amount int ); create table tbl2 ( name varchar(20), amount int ); insert into tbl1 values ('Петр', 100), ('Вася', 200), ('Петр', 100), ('Вася', 200); insert into tbl2 values ('Петр', 100), ('Вася', 200), ('Петр', 100), ('Вася', 200);
 hidden batch(es)


select * from tbl1; select * from tbl2;
name amount
Петр 100
Вася 200
Петр 100
Вася 200
name amount
Петр 100
Вася 200
Петр 100
Вася 200
 hidden batch(es)


select name, amount from tbl1 union select name, amount from tbl2;
name amount
Петр 100
Вася 200
 hidden batch(es)


select name, amount from tbl1 union all select name, amount from tbl2;
name amount
Петр 100
Вася 200
Петр 100
Вася 200
Петр 100
Вася 200
Петр 100
Вася 200
 hidden batch(es)


select name, sum(amount) from ( select name, amount from tbl1 union all select name, amount from tbl2 ) t group by name;
name sum(amount)
Вася 800
Петр 400
 hidden batch(es)