By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table t (
id int not null primary key auto_increment,
a int,
b int,
c int
);
insert into t(a, b, c) values
( 1, 1, 1),
( 2, null, 2),
(null, 3, 3),
( 4, 4, 4);
select sum(value)
from t, lateral (
select a union all
select b union all
select c
) as x(value);
sum(value) |
---|
25 |