How to find sums?????? [message #7414] |
Thu, 12 June 2003 03:36 |
sachin kumar gupta
Messages: 157 Registered: March 2003
|
Senior Member |
|
|
Hello,
I want to find sum in foll O/P form:
Col1 Col2 Col3 Col4
fdg ert er 12
wer rfg 14
--------
Sum 26
dsaf fdg g 3
sf ewr 13
----------
Sum 16
fg 34 234 18
---------------------------------------------
Total 60
& this one also:
Col1 Sum(Col2)
sfsdf 2
dwfwed 4
sdfsdf 5
fsdf 5
-----------
Sum 16
Kindly suggest me the methods for both the queries.
Thanks in Adv.
Sachin
|
|
|
Re: How to find sums?????? [message #7417 is a reply to message #7414] |
Thu, 12 June 2003 08:43 |
MikeT
Messages: 11 Registered: August 2002
|
Junior Member |
|
|
Need more info...basically, from what you have there:
Query 1:
select sum(Col4)
from yourtable
Query 2:
select sum(Col2)
from yourtable
...but something tells me this is not what you really want.
|
|
|
|
Re: How to find sums?????? [message #7460 is a reply to message #7451] |
Mon, 16 June 2003 07:30 |
Mike T
Messages: 32 Registered: August 2002
|
Member |
|
|
In SQL Plus:
CLEAR BREAKS
CLEAR COMPUTES
BREAK ON REPORT
COMPUTE SUM OF 'purchasing' ON REPORT
select month, sum(purchasing) as purchasing
from table
group by month;
If you have more fields you want to SELECT, add them to the GROUP BY, and add "BREAK ON MONTH" and a "COMPUTE SUM" for your subtotals by Month:
CLEAR BREAKS
CLEAR COMPUTES
BREAK ON 'month' SKIP 1
COMPUTE SUM OF 'purchasing' ON 'month'
COMPUTE SUM OF 'purchasing' ON REPORT
select field1, field2, month, sum(purchasing) as purchasing
from table
group by field1, field2, month;
Hope that helps
-- Mike
|
|
|
|