Monday, March 12, 2012

Oracle SQL: Agg. Fn. Calculation

Hi All,

I don't know if it is possible but can you do something like this:

SELECT Sum(columnX) As calc1, Sum(columnY) As calc2, (calc1 - calc2) As Difference FROM ... WHERE ... GROUP BY ...

Otherwise I'd have to do this:
SELECT Sum(columnX) As calc1, Sum(columnY) As calc2, (Sum(columnX) - Sum(columnY)) As Difference FROM ... WHERE ... GROUP BY ...

So instead of calculating the sum twice, I have to do it four times... is there any way to improve this? I've searched everything I could and I found nothing (maybe I was using the wrong keywords, but I'm pretty sure I tried thme all!)

Thanks in Advance!
WarrenOracle will do the SUM only once for each column and at the end do the calculations!
;)|||See that's what I like to hear...!

Where do I find info like that?

Thank you!
Anthony|||I learned it since Oracle 7, but wouldn't know the specific manual to refer you to.
In any case you may begin your research anywhere here:

ORACLE FAQ:
http://www.orafaq.com/
http://www.oracle-base.com/Index.php
http://www.ixora.com.au/q+a/index.html
http://www.llcsystems.com/FAQ.htm

Error Message:
http://www-rohan.sdsu.edu/doc/oracl...4625_01/toc.htm

Tips:
http://www.arikaplan.com/oracle.html

General:
http://www.csee.umbc.edu/help/
http://www.ss64.com/index.html
http://news.dcn-asu.ru/BOOKS/
http://www.daimi.au.dk/~oracle/sql/
http://www-rohan.sdsu.edu/doc/oracl...4625_01/toc.htm

Oracle 8i Database Books:

http://otn.oracle.com/pls/tahiti/tahiti.docindex

For Oracle Report Documentation:

http://www-kryo.desy.de/documents/O...n_features.html

http://dba-oracle.com/oracle_news/2004_1_21_rittman.htm

http://otn.oracle.com/documentation/reports.html
http://otn.oracle.com/products/repo...rted/index.html
:)|||And I thank you...!

Warren

No comments:

Post a Comment