Re: Random not so random

From: Jean-Luc Lachance <jllachan(at)sympatico(dot)ca>
To: Arnau Rebassa <arebassa(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Random not so random
Date: 2004-10-01 17:13:33
Message-ID: 415D903D.4010203@sympatico.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Use a SERIAL id on messages, then

Select * from messages
where id = int8( random() * currval({sequence_name}));

Arnau Rebassa wrote:

> Hi everybody,
>
> I'm doing the following query:
>
> select * from messages order by random() limit 1;
>
> in the table messages I have more than 200 messages and a lot of times,
> the message retrieved is the same. Anybody knows how I could do a more
> "random" random?
>
> Thank you very much
>
> --
> Arnau
>
> _________________________________________________________________
> Consigue aquí las mejores y mas recientes ofertas de trabajo EE.UU.
> http://latino.msn.com/empleos
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2004-10-01 18:28:33 Re: Aggregates ?? Datamart (to whatever it has implemented a DataMart using Postgres)
Previous Message Ashok...... 2004-10-01 17:01:18 Arjunt......