From: G. Anthony Reina <reina@nsi.edu>
To: Kyle Bateman <kyle@actarg.com>
To: pgsql-sql@postgreSQL.org <pgsql-sql@postgreSQL.org>
Subject: Re: [SQL] sum of two queries
Date: Thu, 22 Apr 1999 14:23:54 -0700
Message-ID: <371F936A.142DBA48@nsi.edu> (raw)
References: <371F5BBF.874251FD@actarg.com>
<371F5CE9.98C540FD@nsi.edu>
<371F6724.C05E431@actarg.com>
Kyle Bateman wrote:
>>
>
> I explained my problem badly.
>
> Here's the full thing. I'm doing this, which works:
>
> select -sum(tquant) from mtr_reg where
> status = 'clsd' and
> fr_proj = 20 and
> pnum = '1122'
> union
> select sum(tquant) from mtr_reg where
> status = 'clsd' and
> to_proj = 20 and
> pnum = '1122'
> ;
I think this will work (it seems to work when I tried it with my
database):
select sum(a.tquant - b.tquant) from mtr_reg as a, mtr_reg as b where
a.status = 'clsd' and
b.status = 'clsd' and a.pnum = '1122' and b.pnum = '1122' and a.fr_proj
= 20 and b.to_proj = 20;
-Tony
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: reina@nsi.edu, kyle@actarg.com
Subject: Re: [SQL] sum of two queries
In-Reply-To: <371F936A.142DBA48@nsi.edu>
References: <371F5BBF.874251FD@actarg.com> <371F5CE9.98C540FD@nsi.edu> <371F6724.C05E431@actarg.com> <371F936A.142DBA48@nsi.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox