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

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: [Fwd: Re: surprising results with random()]
Date: 2009-02-23 23:21:50
Message-ID: 49A32F8E.5090701@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Brent Wood 2009-02-23 23:24:05 Re: surprising results with random()
Previous Message ries van Twisk 2009-02-23 23:12:10 Re: surprising results with random()