这个问题在这里已经有答案了:
postgresql:generate sequence (2个答案)
10个月前关门了。
我得到了前20行要解决的查询,但我不知道如何将其扩展到5行
prepare dna_length(int) as
with t1 as (
select chr(65) as s
union select chr(67)
union select chr(71)
union select chr(84) )
, t2 as ( select s,
row_number() over() as rn from t1)
, t3 as ( select generate_series(1,$1) as i,
round(random() * 4 + 0.5) as rn )
, t4 as ( select t2.s
from t2 join t3 on (t2.rn=t3.rn))
select
array_to_string(array(select s from t4),'') as dna ;
在此处输入图像描述
1条答案
按热度按时间ycggw6v21#
这对你有用吗?你可以把1美元放回去换掉20美元
t3
如果是的话。