Home » SQL & PL/SQL » SQL & PL/SQL » Oracle10g (How to show row wise as well as column wise sum)
Oracle10g [message #392109] Mon, 16 March 2009 07:33 Go to next message
sr_orcl
Messages: 82
Registered: January 2009
Location: mumbai
Member

Hi To all Experts,

I want the result as shown in the xls file.For the table emp(testing table only).
Please tell me how can i show rowwise sum as well cloumn wise sum.
  • Attachment: t1.csv
    (Size: 0.21KB, Downloaded 103 times)
Re: Oracle10g [message #392110 is a reply to message #392109] Mon, 16 March 2009 07:38 Go to previous messageGo to next message
ramoradba
Messages: 2454
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
Please read the forum guidelines before posting. and
you need to help us by providing the DDL/DML which you tried. and you need to copy and paste the out put.
most of us are not able to download the attachments.so please follow the post guidelines.
so that the forum will help you

Thanks & regards
Sriram

[Updated on: Mon, 16 March 2009 07:39]

Report message to a moderator

Re: Oracle10g [message #392111 is a reply to message #392109] Mon, 16 March 2009 07:44 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I can't read your file but given the question I recommend to read about "group by cube".

Regards
Michel
Re: Oracle10g [message #392122 is a reply to message #392111] Mon, 16 March 2009 08:55 Go to previous message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member

Try this code

SELECT   SAL.DEPTNO,sal.SAL Sal,nvl(bon.COMM,0) COMM,
         sum(sal.SAL + nvl(bon.COMM,0)) TOTAL
FROM     SCOTT.emp sal,SCOTT.emp bon
WHERE    SAL.EMPNO=bon.EMPNO(+)
GROUP BY  SAL.DEPTNO,sal.SAL,nvl(bon.COMM,0)
UNION 
SELECT   NULL DEPTNO,SUM(sal.SAL) Sal,SUM(nvl(bon.COMM,0)) COMM,NULL TOTAL 
FROM     SCOTT.emp sal,SCOTT.emp bon
WHERE    SAL.EMPNO=bon.EMPNO(+) ;
Previous Topic: two-task save area overflow
Next Topic: how to use between
Goto Forum:
  


Current Time: Tue Dec 06 00:03:25 CST 2016

Total time taken to generate the page: 0.20901 seconds