Re: select a random record

Поиск
Список
Период
Сортировка
От A_Schnabel@t-online.de (Andre Schnabel)
Тема Re: select a random record
Дата
Msg-id 00a501c132b4$b5052580$0201a8c0@aschnabel.homeip.net
обсуждение исходный текст
Ответ на select a random record  (bj@zuto.de (Rainer Clasen))
Список pgsql-general
----- Original Message -----
From: "Rainer Clasen" <bj@zuto.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);




В списке pgsql-general по дате отправления:

Предыдущее
От: Tod McQuillin
Дата:
Сообщение: Re: select a random record
Следующее
От: Michael Meskes
Дата:
Сообщение: Re: Embedded SQL vulnerability