Search Postgresql Archives

Strange behavior of the random() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
Can anybody explain me that strange behavior?

 select random() as "rnd", random() as "rnd1", random() as "rnd2"
 from generate_series( 1, 5 );
 ---
 0.948556384071708	0.769186236895621	0.381390900816768
 0.684488877654076	0.594888080842793	0.214444123208523
 0.668408528901637	0.452859566546977	0.924952184315771

All of the values are different.

 select random() as "rnd", random() as "rnd1", random() as "rnd2"
 from generate_series( 1, 3 )
 order by random();
 ---
 0.166236794553697	0.166236794553697	0.166236794553697
 0.629051928408444	0.629051928408444	0.629051928408444
 0.698161978274584	0.698161978274584	0.698161978274584

All values in any row are the same.

 select random() as "rnd", random() as "rnd1", random() as "rnd2"
 from generate_series( 1, 3 )
 order by random() || 'test';
 ---
 0.569052047561854	0.531697370111942	0.338135569822043
 0.880468992516398	0.172520748339593	0.0296505615115166
 0.862012444529682	0.119546371512115	0.21626165881753

All of the values are different again.

Is it a bug?




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux