Skip site navigation (1) Skip section navigation (2)

Re: Limiting the result set

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Rob <rob(at)jamwarehouse(dot)com>
Cc: pgNovice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Limiting the result set
Date: 2002-08-16 12:40:22
Message-ID: 20020816124022.GA14620@wolff.to (view raw or flat)
Thread:
Lists: pgsql-novice
On Fri, Aug 16, 2002 at 10:06:23 +0200,
  Rob <rob(at)jamwarehouse(dot)com> wrote:
> 
> Is there any way, IN ONE QUERY, to do this.  So I want to basically return
> the first 500 results
> and a count of the total result set in one go.  Is this possible?
> 
> If not, what would be the quickest way to do this?  The reason I need one
> query is because I use
> dynamic SQL, which complicates stuff a bit more

It is certainly possible to do this, if not efficient.

You can always just union two queries together using an extra column that
is null for the real records and returns the full count in a special
record. Order by can be used to make this record first or last.

In response to

pgsql-novice by date

Next:From: Mark NelsonDate: 2002-08-16 13:52:10
Subject: Is my database done for?
Previous:From: RobDate: 2002-08-16 08:06:23
Subject: Limiting the result set

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group