show sum [message #310985] |
Thu, 03 April 2008 03:01 |
gozuhair
Messages: 206 Registered: January 2008
|
Senior Member |
|
|
Dear All
please help.
Create table abc
(sal number(5),empno varchar2(5));
insert into abc
(100,1)
insert into abc
(100,2)
insert into abc
(1000,3)
commit;
I want the following output using select statement.
sal empno
100 1
100 2
1000 3
1200
regards
Zuhair
[Updated on: Thu, 03 April 2008 03:06] by Moderator Report message to a moderator
|
|
|
|
|
Re: show sum [message #310992 is a reply to message #310987] |
Thu, 03 April 2008 03:26 |
gozuhair
Messages: 206 Registered: January 2008
|
Senior Member |
|
|
Create table abc (
sal number(5),
empNo varchar2(5));
insert into abc
values (100,
1);
insert into abc
values (100,
2);
insert into abc
values (1000,
3);
commit;
Need sum of 100+100+1000 at the end of rows selected like this
sal
100
100
1000
1200
|
|
|
|
Re: show sum [message #310996 is a reply to message #310995] |
Thu, 03 April 2008 03:38 |
gozuhair
Messages: 206 Registered: January 2008
|
Senior Member |
|
|
by using rollup function sum of salary show in each row but i want sum of all rows on the last line not each record.
|
|
|
|
Re: show sum [message #311007 is a reply to message #310985] |
Thu, 03 April 2008 04:01 |
gozuhair
Messages: 206 Registered: January 2008
|
Senior Member |
|
|
I am using the following query
SELECT empNo,
sal
FROM abc
GROUP BY ROLLUP(sal,empNo);
The above query show the following output.
EMPNO SAL
----- ---------
100 1
1
100 2
2
1000 3
3
Desired Output.
EMPNO SAL
----- ---------
100 1
100 2
1000 3
1200
(means 1200 equal to 100+100+1000)
|
|
|
|
Re: show sum [message #311070 is a reply to message #310985] |
Thu, 03 April 2008 05:58 |
gozuhair
Messages: 206 Registered: January 2008
|
Senior Member |
|
|
I am using the following query
SELECT empNo,
sal
FROM abc
GROUP BY ROLLUP(sal,empNo);
The above query show the following output.
EMPNO SAL
----- ---------
100 1
1
100 2
2
1000 3
3
Desired Output.
EMPNO SAL
----- ---------
100 1
100 2
1000 3
1200
(means 1200 equal to 100+100+1000)
|
|
|
Re: show sum [message #311071 is a reply to message #311070] |
Thu, 03 April 2008 06:02 |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
Have a look at the Grouping function. You can use this to restrict the rows that you don't want to see.
|
|
|
|
|
|
|
|