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

Re: Column as result of subtraction of two other columns?

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jean-Luc Lachance <jllachan(at)sympatico(dot)ca>,Mark Cave-Ayland <m(dot)cave-ayland(at)webbased(dot)co(dot)uk>,pgsql-general(at)postgresql(dot)org
Subject: Re: Column as result of subtraction of two other columns?
Date: 2004-08-23 16:59:04
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Fri, 16 Jul 2004 12:04:54 -0400, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>	select sum(x), sum(y), sum(x)-sum(y) from ...
>At least since 7.4, the system will notice the duplicate aggregates
>and run only two summations to compute the above, followed by a single
>subtraction at the end.  The apparently more intelligent way suggested
>by Jean will have to run three summations, and thus end up being a net

Also note that Jean-Luc's
	select sum( x), sum( y), sum(x-y) from whatever group by z;
gives a different result in the presence of NULLs.


In response to

pgsql-general by date

Next:From: A PalmbladDate: 2004-08-23 17:51:21
Subject: Re: database troubles - various errors
Previous:From: Stephan SzaboDate: 2004-08-23 16:56:26
Subject: Re: Why does =ANY(<array>) need an extra cast when used

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