By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
select concat(a,b,c,d)
from (select 'a','b','c','d') as t(a,b,c,d)
group by cube(a,b,c,d)
having len(concat(a,b,c,d)) = 3
(No column name) |
---|
bcd |
acd |
abd |
abc |
select coalesce(a, 0) + coalesce(b, 0) + coalesce(c, 0) + coalesce(d, 0)
from (values (1, 2, 3, 4)) t(a,b,c,d)
group by cube(a,b,c,d)
having (case when a is not null then 1 else 0 end +
case when b is not null then 1 else 0 end +
case when c is not null then 1 else 0 end +
case when d is not null then 1 else 0 end
) = 3
(No column name) |
---|
9 |
8 |
7 |
6 |
with t as (
select t.*
from (values (1), (2), (3), (4)) t(x)
)
select t1.x + t2.x + t3.x
from t t1 join
t t2
on t1.x < t2.x join
t t3
on t2.x < t3.x
(No column name) |
---|
6 |
7 |
8 |
9 |