小编use*_*355的帖子

postgres随机使用setseed

我想在表中添加一个随机数列setseed.

原始表结构 (test_input) col_a,col_b,col_c

期望的输出 (test_output) col_a, col_b, col_c, random_id

以下内容random_id在所有行上返回相同的内容,而不是在每行中返回不同的值.

select col_a,col_b,col_c,setseed(0.5),(
     select random() from generate_series(1,100) limit 1
     ) as random_id 
from test_input
Run Code Online (Sandbox Code Playgroud)

你能帮我修改一下使用的查询setseedrandom_id在每一行中返回一个不同的查询吗?

random postgresql sample random-seed

5
推荐指数
1
解决办法
6480
查看次数

标签 统计

postgresql ×1

random ×1

random-seed ×1

sample ×1