random

Поиск
Список
Период
Сортировка
От Jelle Ouwerkerk
Тема random
Дата
Msg-id Pine.NEB.4.10.10103051400050.13137-100000@what.openface.ca
обсуждение исходный текст
Ответы Re: random  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: random  (Tomek Zielonka <tomek-lists@mult.i.pl>)
Список pgsql-sql
Hi

What would be the best way to select a random row from a result set?

Possibilities:

1) o get the total number of rows using count()  o generate a random number between 1 and the total  o select the n'th
rowusing OFFSET
 

2) o get the total number of rows using count()  o generate a random number between 1 and the total  o fetch n times

Option 1 uses 'OFFSET' which is a database-specific keyword, which is
probably bad. 

Also, is there a way to randomize the order of a result set?

Thanks in advance

Jelle Ouwerkerk
Software Developer 
Openface Internet Inc.
Montreal, Quebec, Canada
http://www.openface.ca



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

Предыдущее
От: David Olbersen
Дата:
Сообщение: Re: How do I use text script containing SQL?
Следующее
От: wade
Дата:
Сообщение: pl/pgsql and returning rows