Re: get certain # of recs

From: Patrik Kudo <kudo(at)partitur(dot)se>
To: "Mike S(dot) Nowostawsky" <mikenowo(at)sympatico(dot)ca>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: get certain # of recs
Date: 2001-09-14 21:09:11
Message-ID: Pine.BSF.4.31.0109142307300.26062-100000@tb303.partitur.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 13 Sep 2001, Mike S. Nowostawsky wrote:

> How can one select only a certain number of records in Postgres?
>
> In other SQL langs we can use, say, for the first 20 recs:
>
> select * from tablename where rownum < 21;

You could use

select * from tablename limit 20

If you need to sort in some way you could use something like

select col1, col2, ... coln from tablename order by col1 limit 20

Regards,
Patrik Kudo

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Linh Luong 2001-09-14 21:26:46 Diabling constraints
Previous Message Mark E. Pennell 2001-09-14 21:06:13 Transition from MS-SQL - Store Procedures?