Re: Aggregate functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "John Duffy" <jbduffy(at)cwcom(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Aggregate functions
Date: 2001-02-04 19:50:24
Message-ID: 6887.981316224@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"John Duffy" <jbduffy(at)cwcom(dot)net> writes:
> What I would like to be able to do is a select like this:
> SELECT equity_id, start_date(price), end_date(price), min(price),
> max(price)
> Are there aggregate function, such as 'first' and 'last', that will store
> the first and last row value of a series of rows ?

Don't min(date) and max(date) do what you want? If not, please explain
what you want more carefully.

"First" and "last" aggregates would be trivial to write, but I doubt
they'd be useful for anything, because the rows of the table are not
guaranteed to be delivered to the aggregate function in any particular
order. In general SQL does not believe that row ordering is a
meaningful concept --- ORDER BY is a decoration to produce nice-looking
output for human consumption, not part of the computational model. So
you need to define the results you want without reference to row order.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tim Barnard 2001-02-04 20:29:03 7.1 question
Previous Message John Duffy 2001-02-04 19:28:04 Aggregate functions