Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.oracle -> Re: Calculations in queries - How?

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@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 Sat Mar 20 2004 - 19:47:06 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US