Re: Random Sample

From: "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at>
To: <tom(at)tacocat(dot)net>, <pgsql-general(at)postgresql(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Random Sample
Date: 2007-05-21 06:38:34
Message-ID: AFCCBB403D7E7A4581E48F20AF3E5DB202C5B1AA@EXADV1.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> How do I pull a random sample of either 100 records or 5% of the
> population of a table?

SELECT table.* FROM table
ORDER BY random()
LIMIT n;

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rodrigo De León 2007-05-21 07:13:10 Re: doverlaps() returns null
Previous Message georgy.slavov 2007-05-21 06:08:12 Re: pg_ctl: could not start service "pgsql-8.2": error code 1063