From: | Marc Millas <marc(dot)millas(at)mokadb(dot)com> |
---|---|
To: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | some random() clarification needed |
Date: | 2020-07-14 15:14:55 |
Message-ID: | CADX_1aa3BNFvW_ivrao1NJFWFdiYbhDxg9vUGUDZz-7YuRwvqQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
when, in psql, on a postgres 12.3, I write:
select ceiling(random()*2582);
it does provide the expected answer, ie. a number between 1 and 2582,
inclusive.
allways.
when I decide to use this to get a random row within a table prenoms having
2 columns
a id serial, and a prenom varchar, with explicitly 2582 lines, no gaps,
I write:
select id, prenom from prenoms where id=ceiling(random()*2582);
expecting to get, allways, one line.
But its not the case.
around 15% of time I get 0 lines which is already quite strange to me.
but 10% of time, I get a random number of lines, until now up to 4.
even weirder (to me !)
so, can someone please clarify ?
thanks,
regards,
Marc MILLAS
Senior Architect
+33607850334
www.mokadb.com
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2020-07-14 15:24:36 | Re: some random() clarification needed |
Previous Message | Toomas Kristin | 2020-07-14 13:59:20 | Re: Both side privileges |