----- Original Message -----
From: "Rainer Clasen" <bj(at)zuto(dot)de>
Subject: [GENERAL] select a random record
...
>
> This jukebox should offer a random play mode. It should take into account
> when the title was played the last time. My Idea is to submit the query
> returning the records ordered by their last time of play, ignore a random
> number of records, fetch one record and drop the result set.
>
> I'm wondering wether there is a more elegant way to fetch a random record
> from a result.
>
> Rainer
The following select should do it:
SELECT title_name FROM titles
ORDER BY last_played DESC
LIMIT 1
OFFSET ( floor ( random () * 20);