Alban Hertroys wrote:
> I've recently been busy improving a query that yields a fixed
> number of random records matching certain conditions.
> Dear Santa,
>
> I'd like my database to have functionality analogue to how
> LIMIT works,
> but for other - non-sequential - algorithms.
>
> I was thinking along the lines of:
>
> SELECT *
> FROM table
> WHERE condition = true
> RANDOM 5;
Ho, ho, ho.
SELECT *
FROM table
WHERE condition = true
ORDER BY hashfloat8(random())
LIMIT 5;
Yours,
Laurenz Albe