Re: returned row number

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Keith Worthington <keithw(at)narrowpathinc(dot)com>
Cc: PostgreSQL Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: returned row number
Date: 2005-05-06 21:00:16
Message-ID: 20050506210016.GB11254@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Fri, May 06, 2005 at 15:45:02 -0400,
Keith Worthington <keithw(at)narrowpathinc(dot)com> wrote:
> Hi All,
>
> I have a quick question. Is there a simple way to access the returned record
> number?
>
> I want to be able to do something like
>
> SELECT record AS record_no,
> column1,
> column2
> FROM table1
> WHERE column2 < 100
> ORDER BY column1;
>
> record_no | column1 | column2
> ----------+---------+---------
> 1 | A | 1.75
> 2 | F | 93
> 3 | M | 12.5
> 4 | N | 0
> 5 | Q | 57.6

Normally the best thing to do is have the application count.
You can use a subquery to get the counts, but it will be a
lot slower. You could also write a set returning function
to do this.

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Keith Worthington 2005-05-06 21:00:21 Re: returned row number
Previous Message Keith Worthington 2005-05-06 19:45:02 returned row number