Re: Add a ROWCOUNT to the output of a select.

From: "Robins Tharakan" <tharakan(at)gmail(dot)com>
To: "Harald Fuchs" <hari(dot)fuchs(at)googlemail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Add a ROWCOUNT to the output of a select.
Date: 2008-05-14 10:01:54
Message-ID: 36af4bed0805140301i3360c9fbw1a5238dc283161f9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Oops!
Of course, I meant a sequence.

*Robins*

On Wed, May 14, 2008 at 2:10 PM, Harald Fuchs <hari(dot)fuchs(at)googlemail(dot)com>
wrote:

> In article <36af4bed0805131818p147bb440oa4c1944939e3b313(at)mail(dot)gmail(dot)com>,
> "Robins Tharakan" <tharakan(at)gmail(dot)com> writes:
>
> > While we could always check for the query performance reasons, I
> > rather think that this is an overkill for the purpose of mere line
> > numbers.
>
> > If such queries don't change frequently, you could be better off
> > using a simple function that instead adds a 'rownumber' field to the
> > output of the inner SQL query. The 'rownumber' could instead be
> > calculated by simply incrementing it within a FOR loop for each row.
>
> I think a sequence is much simpler:
>
> create temp sequence tmp;
> select nextval('tmp') as rownum,
> contactdate
> from
> myTable
> where
> contactdate > '2007-06-30 23:59:59'
> order by
> contactdate;
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Koczan 2008-05-14 15:46:09 Re: Auto-formatting timestamps?
Previous Message Marcin Stępnicki 2008-05-14 08:48:34 Re: Add a ROWCOUNT to the output of a select.