Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> cummulative result

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: cummulative result
 parth  Posted: Jun 19, 2007 06:52:21 AM

 Total Post: 17
 Joined: Apr, 2007






 hi
i want a result like below:

fir sec
-----------------------------
10 10
20 30
30 60
40 100


please add like above and tell, once i have read about some function for that but cant remember it...!
if any one can !?
parth

 chinna
Posted: Jun 20, 2007 05:03:28 AM  

 Total Post: 28
 Joined: May, 2007






 
HI,
Iam very happy if this explanation helps you.
Intially frequency table with freq column and cfreq(with empty) column
FREQ CFREQ
---- ----------
10
20
30
40
70
15
35

after executing the procedure
EXEC CUMMULATIVE_FREQUENCY
FREQ CFREQ
---- ----------
10 10
20 30
30 60
40 100
70 170
15 185
35 220

----------------------------
PROCEDURE
-----------------------------
V_RES NUMBER(4);
V_RES2 NUMBER(4):=0;
CURSOR C1 IS SELECT FREQ FROM FREQUENCY;
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO V_RES ;
EXIT WHEN C1%NOTFOUND;
V_RES2:=V_RES2+V_RES;
EXECUTE IMMEDIATE 'UPDATE FREQUENCY SET CFREQ=:1 WHERE FREQ=:2' USING V_RES2,V_RES;
END LOOP;
CLOSE C1;

------------------------------------------------------------

REGARDS
SRAWAN


 parth
Posted: Jun 21, 2007 07:58:05 AM  

 Total Post: 17
 Joined: Apr, 2007






 
hi srawan thanx but my question here is, if you dont have any column rather then "Freq" column means no Cfreq column then, above all i dont want to use th procedure for that. so if you can help with the query please...

I am traying to doing it with the Self Join but it seems quite difficult to do,

thanks any ways

chao

~Parth

 Vijay
Posted: Jul 16, 2007 02:16:19 AM  

 Total Post: 12
 Joined: Jul, 2007






 
Hi Parth/Srawan,
There are aggregate functions ROLLUP and CUBE in Oracle.
To get the summary details. You can develop logic to get the cummulative result in there.
Regards.
Vijay Mahawar.

 chinna
Posted: Jul 18, 2007 06:43:53 AM  

 Total Post: 28
 Joined: May, 2007






 
hi,
here is the reqired query for cummulative frequency,.according to my view.
select deptno,sum(deptno) over(order by deptno) "cummulative frequency" from dept
try this.

take care
ok byeeeeeeeeeeeeee

regards
srawan

 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Gopu Gopi334
  Gitesh Trivedi322
  Vinoth Kumar264
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software