Re: Curious behaviour with "order by random()"

2020-06-25 Thread Tom Lane
Erwin Sebastian Andreasen writes: > Compare the output of: > select random(), random(); > which will return 2 separate random values with: > select random(), random() order by random(); > which returns two of the same values (and the same value is also used in > order by). While I use 9.6, I got t

Curious behaviour with "order by random()"

2020-06-25 Thread Erwin Sebastian Andreasen
I wanted to generate some test data based on a subset of rows in a table, thus used ORDER BY RANDOM(). I was surprised to see that if RANDOM() is used in ORDER BY it cannot also be used in column names: the same value is returned. Compare the output of: select random(), random(); which will retu