lundi 29 avril 2019

POSTGRESQL random() gives always the same value for the whole table. How to fix it?

I want to build a sql that generates a 2 column table where the first are series of timestamps and the second is a functon that provides values. For example here is random(). But the random function give me always the same value for the whole table, I want different. How to fix it?

SELECT * FROM generate_series('2008-03-01 00:00'::timestamp,
                              '2008-03-05 12:00',
                              '1 day') as ts, random() as value;

Generated table:

"2008-03-01 00:00:00";0.816707271616906
"2008-03-02 00:00:00";0.816707271616906
"2008-03-03 00:00:00";0.816707271616906
"2008-03-04 00:00:00";0.816707271616906
"2008-03-05 00:00:00";0.816707271616906




Aucun commentaire:

Enregistrer un commentaire