Re: Calculations in queries - How?

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 20 Mar 2004 17:47:06 -0800
Message-ID: <2687bb95.0403201747.1bec9292_at_posting.google.com>


starshipdb_at_hotmail.com (C. Lo) wrote in message news:<713a6263.0403201142.311ac391_at_posting.google.com>...
> Hi
>
> I'm wondering if there is a way of having a query return a calculation
> of multiple attributes
>
> ie - something like:
> SELECT (A+B) as sum
> FROm Table
>
> or more complicated:
> SELECT (C.number-(select count(*) from A)-(select count(*) from B)) AS
> diff
> FROM C
>
> Thanks

A better form for the first query would be select sum(colA + colB) from ....

You have several options available to you for the second query. Under the assumption that C is not a single row table then this query appears to be a canidate where the WITH clause may be useful, or you could join C to an inline view calculation of the counts of A - B.

HTH -- Mark D Powell -- Received on Sun Mar 21 2004 - 02:47:06 CET

Original text of this message