I am trying to update a table of 100 already existing rows with 100 random values from a Gaussian distribution, for which I am using the normal_rand
function from the tablefunc
extension. Since this is a set-returning function I placed it it the FROM
-clause.
UPDATE foo
SET bar = r
FROM normal_rand(100, 0, 1) AS r;
However, when executing the statement, all rows in the table are assigned the same value (presumably the first), as such:
bar
-------
0.2451
0.2451
0.2451
...
0.2451
I also tried generate_series
, but this yields similar results. How can I assign the first value of normal_rand(100, 0, 1) to the first row, the second to the second etc.?