|
〇〇 发表于 2022-11-4 11:50
改写错在哪里with recursive f(n,f) as ( ------- 构造阶乘表select 0,1 union allselect n+1,f*(n+1) fro ...
对values语法不熟悉导致
with recursive f(n,f) as ( ------- 构造阶乘表
select 0,1
union all
select n+1,f*(n+1) from f where n<10
)
,t(n,s,f) as (
select 1,lv-1,1 from (values(1),(2))s(lv)
union all
select t.n+1,t.s+f.n,t.f*f.f
from t
,f
where t.n<4 and f.n<=t.n+1
)
select sum(f.f/t.f) from t,f where t.n=4 and t.s>0 and t.s=f.n;
|
|