Re: RANDOM function?

From: Einar Karttunen <ekarttun(at)cs(dot)Helsinki(dot)FI>
To: macky <macky(at)edsamail(dot)com>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: RANDOM function?
Date: 2001-07-31 05:50:53
Message-ID: Pine.LNX.4.33.0107310847510.16977-100000@melkinpaasi.cs.Helsinki.FI
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Tue, 31 Jul 2001, macky wrote:

> can someone point me to the documentation of RANDOM() function....
>
> and can i insert RANDOM POSTIVE WHOLE NUMBERS...?
>
> create table table_name (key int4);
>
> insert into table_name(key) values(random()); <-- this gives me a value of
> 1 and 0 only..
>
random produces a float between 0 and 1. Just multiple it with the
interval you want and you will get the random number you want.

eg. to get a random number between 0 and 100 -> 100 * random().
between 32 and 40 -> (8 * random()) + 32.

- Einar Karttunen

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message macky 2001-07-31 05:55:28 Re: RANDOM function?
Previous Message macky 2001-07-31 05:41:43 RANDOM function?