Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How can we calculate the SUM and AVG in same query?

948562Aug 9 2012 — edited Aug 10 2012
CREATE TABLE Sales (Month VARCHAR(20) ,SaleAmount INT)


INSERT INTO Sales VALUES ('January', 100)
INSERT INTO Sales VALUES ('February', 200)
INSERT INTO Sales VALUES ('March', 300)

SELECT * FROM SALES
 

Month             SaleAmount
—————-  ———–
January           100
February          200
March             300 

desired output :

top_month     AVG       SUM

March             200        600
The number of rows is dynamic.

Edited by: 945559 on Aug 9, 2012 1:39 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 7 2012
Added on Aug 9 2012
4 comments
1,084 views