Re: random rows

From: "Joao Pedro M(dot) F(dot) Monoo" <jpedro(at)infortrade(dot)com(dot)br>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: random rows
Date: 2001-04-26 19:18:49
Message-ID: 001701c0ce85$b988dae0$06ffa8c0@infortrade.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general pgsql-sql

Hi!

> How I can return random N rows from my select stmt?
> like:
> e.g. what my selectee is a set of 1000 rows, I want randomly
> pickup 100 of 1000.

use the LIMIT clause

example

SELECT * FROM test_table LIMIT 100;

you can also use the OFFSET clause to skip to n row and the fetch the n
desired rows

example

SELECT * FROM test_table LIMIT 100 OFFSET 100;

this will skip to row number 100 and the fetch the next 100 rows

[]s
---------------------------------------------
Joao Pedro M. F. Monoo
Infortrade Information Systems
#183816 Linux Registered User
Slackware 7.1 running 2.4.2 Linux Kernel

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Jie Liang 2001-04-26 19:29:22 Re: random rows
Previous Message Joel Burton 2001-04-26 19:18:29 Re: random rows

Browse pgsql-general by date

  From Date Subject
Next Message Gregory Wood 2001-04-26 19:19:39 Re: help with serial type
Previous Message Joel Burton 2001-04-26 19:18:29 Re: random rows

Browse pgsql-sql by date

  From Date Subject
Next Message Jie Liang 2001-04-26 19:29:22 Re: random rows
Previous Message Joel Burton 2001-04-26 19:18:29 Re: random rows