Re: select 2 random rows
От
Josh Berkus
Тема
Re: select 2 random rows
Дата
Msg-id
200206271558.00392.josh@agliodbs.com
Ответ на
select 2 random rows (Rory Campbell-Lange)
Список
Дерево обсуждения
select 2 random rows Rory Campbell-Lange <rory@campbell-lange.net>
Re: select 2 random rows Josh Berkus <josh@agliodbs.com>
command length? stev knowles <stev@Precision.Guesswork.COM>
Re: command length? Josh Berkus <josh@agliodbs.com>
Re: command length? stev knowles <stev@Precision.Guesswork.COM>
Re: command length? Josh Berkus <josh@agliodbs.com>
Re: command length? stev knowles <stev@Precision.Guesswork.COM>
Re: command length? Manfred Koizar <mkoi-pg@aon.at>
Re: command length? stev knowles <stev@Precision.Guesswork.COM>
Re: command length? Tom Lane <tgl@sss.pgh.pa.us>
new behavior stev knowles <stev@Precision.Guesswork.COM>
Rory, > I'd like to select 2 random rows from a table. > At the moment I'm returning a couple of hundred rows into a perl hash > and randomising it there, but it would be great if I could do it in the > database call. > > Each row has an id number created using the SERIAL type. This is actually quite easy: SELECT *, RANDOM() as random_sort FROM the_table ORDER BY random_sort LIMIT 2; -- -Josh Berkus
В списке pgsql-novice по дате отправления