Search Postgresql Archives

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

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

 



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?







--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[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