| From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
|---|---|
| To: | Heiko Klein <Heiko(dot)Klein(at)met(dot)no> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: selecting random row |
| Date: | 2002-04-02 07:42:55 |
| Message-ID: | 20020402174255.C4927@svana.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Tue, Apr 02, 2002 at 06:57:21AM +0000, Heiko Klein wrote:
> Hi,
>
> out of a table i.e. people:
> id last first sex age address
>
> I would like to select a random id. Id's are a sequence, but some
> peoble have been deleted, so there are several id-holes in the
> table.
>
> Furthermore, I would like to specify the random person, like
>
> select 'random person id' from table where age > 60 and sex = 'm';
select * from table where age > 60 and sex = 'm' order by random() limit 1;
IIRC
HTH,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Ignorance continues to thrive when intelligent people choose to do
> nothing. Speaking out against censorship and ignorance is the imperative
> of all intelligent people.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Daniel Lundin | 2002-04-02 07:50:31 | Re: selecting random row |
| Previous Message | Dominic J. Eidson | 2002-04-02 07:29:32 | Re: Errors when running vacuumdb... |