Re: Probably simple answer

From: Andrew Gould <andrewgould(at)yahoo(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: postgresql <pgsql(at)symcom(dot)com>, Al Kirkus <Al(at)dist102(dot)k12(dot)il(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: Probably simple answer
Date: 2001-11-09 01:01:16
Message-ID: 20011109010116.60146.qmail@web13404.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks. Sometimes there's just no getting around a
little work. :-)

Andrew Gould

--- Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> Andrew Gould writes:
>
> > I think he simply wants the rows of the result set
> > numbered from 1 to whatever the last row is. This
> is
> > useful for referencing rows when discussing
> reports.
> > It is also an immense help when calculating a
> record's
> > statistical percentile ranking.
> >
> > Doing it in a table is no problem. But how do you
> > create one dynamically in a select query?
>
> It's not easily possible.
>
> Even if you were to write a server-side function
> that would implement such
> a counter, there is no guarantee that the rows would
> be returned in the
> order that the function is called in. (Depending on
> how you express the
> query it can be very likely, but there is no
> guarantee.)
>
> It gets worse if you use ORDER BY or DISTINCT. Then
> the problem amounts
> to adding a column to the result set after sorting,
> which is not possible
> in the SQL query model.
>
> So by far the easiest choice is to keep this counter
> in the client
> application as you loop through the result set.
>
> --
> Peter Eisentraut peter_e(at)gmx(dot)net
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to
majordomo(at)postgresql(dot)org

__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mayan 2001-11-09 01:19:34 Help installing PGSQL 7.1 on Linux
Previous Message Peter Eisentraut 2001-11-08 23:41:04 Re: Probably simple answer