Re: Getting a random row

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Shaul Dar, 13.10.2009 17:17:
Also PG does not have a concept of an auto-increment pseudo-column
like Oracle's "rownum". Any suggestions?

Yes it does (at least 8.4)

SELECT row_number() over(), the_other_columns...
FROM your_table

So you could do something like:

SELECT * FROM ( SELECT row_number() over() as rownum, the_other_columns...
 FROM your_table
) t WHERE t.rownum = a_random_integer_value_lower_than_rowcount;

Thomas




--
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux