If you want 1 row per id, you could do

```
select id
,x1*x1 as result1
,x2*x2+x3*x3 as result2
,x1*x1+x2*x2 as result3
,x3*x3 as result4
,x1*x1+x3*x3 as result5
,x2*x2 as result6
from t
;
```

which will give you

```
id result1 result2 result3 result4 result5 result6
5555 16 34 25 25 41 9
6666 9 65 25 49 58 16
7777 4 8 8 4 8 4
```

Doing exactly the same using power function

```
select id
,power(x1,2) as result1
,power(x2,2)+power(x3,2) as result2
,power(x1,2)+power(x2,2) as result3
,power(x3,2) as result4
,power(x1,2)+power(x3,2) as result5
,power(x2,2) as result6
from t
;
```

Now - if you want 3 rows per id (as you indicated in your question), you could do

```
select a.id
,case b.n
when 1 then x1*x1
when 2 then x1*x1+x2*x2
when 3 then x1*x1+x3*x3
end as result1
,case b.n
when 1 then x2*x2+x3*x3
when 2 then x3*x3
when 3 then x2*x2
end as result2
from t as a
outer apply (values(1),(2),(3)) as b(n)
order by a.id
;
```

which will give you

```
id result1 result2
5555 16 34
5555 25 25
5555 41 9
6666 9 65
6666 25 49
6666 58 16
7777 4 8
7777 8 4
7777 8 4
```

Or you could do

```
select id
,result1
,result2
from ( select id
,x1*x1 as result1
,x2*x2+x3*x3 as result2
from t
union all select id
,x1*x1+x2*x2 as result1
,x3*x3 as result2
from t
union all select id
,x1*x1+x3*x3 as result1
,x2*x2 as result2
from t
) as a
order by id
;
```