selecting random row

Поиск
Список
Период
Сортировка
От Heiko Klein
Тема selecting random row
Дата
Msg-id 15529.22097.741513.348736@polar.oslo.dnmi.no
обсуждение исходный текст
Ответы Re: selecting random row  (Martijn van Oosterhout <kleptog@svana.org>)
Re: selecting random row  (Daniel Lundin <daniel@helena-daniel.se>)
Список pgsql-general
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';



Right now (in perl), I select the complete list of id's into a @list, do
a $id = $list[rand(@list)] and have the right row. But this seems to be
very time-consuming, and I would like to have it done completely in the
Pg-database.

Regards,

Heiko

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Errors when running vacuumdb...
Следующее
От: Vernon Wu
Дата:
Сообщение: Using inheritance - a table design question