[Fwd: Re: surprising results with random()]

Поиск
Список
Период
Сортировка
От John R Pierce
Тема [Fwd: Re: surprising results with random()]
Дата
Msg-id 49A32F8E.5090701@hogranch.com
обсуждение исходный текст
Ответы Re: [Fwd: Re: surprising results with random()]  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
ries van Twisk wrote:

>
> Jessi,
>
> should the function not look like this???
>
> CREATE OR REPLACE VIEW test_view AS
> SELECT
>     CASE
>         WHEN random() < .333333333 THEN '1'
>         WHEN random() < .5 THEN '2'
>         ELSE '3'
>     END AS test_value
>
> FROM client;


actually, I'd think that should be .66666


but... wouldn't    floor(random() * 3.0) + 1  be a simpler way to do this?







В списке pgsql-general по дате отправления:

Предыдущее
От: ries van Twisk
Дата:
Сообщение: Re: surprising results with random()
Следующее
От: "Brent Wood"
Дата:
Сообщение: Re: surprising results with random()