Oracle Analytical Functions [message #87893] |
Fri, 19 October 2001 10:22 |
Erin
Messages: 17 Registered: October 2001
|
Junior Member |
|
|
I'm trying to use the Sum function in Discoverer that uses the Range Between functionality.
SUM(n) OVER (PARTITION BY expr1 ORDER BY expr2 RANGE BETWEEN expr3 AND expr4)
I can't seem to get this to work. Does anyone have some sample code I can look at using this function. I really need to sum a dollar amount between 2 date ranges to determine a YTD value. Thanks.
----------------------------------------------------------------------
|
|
|
Re: Oracle Analytical Functions [message #87924 is a reply to message #87893] |
Tue, 30 October 2001 20:47 |
Ashok kumar .D
Messages: 1 Registered: October 2001
|
Junior Member |
|
|
I had got the same problem.but i could solve it using User defiend functions
Ex
select GetCurrentYearYTD(Year,Month),Actual,Budget,.... from my table
where perio_id between # and #
i wrote the function like the following :
function GetCurrentYearYTD(Year , Month)
returnval number
select sum(actual) into returnval from mytable
where period_year=year and period_month between 1 and Month.
since my db is larget it is giving performance issues. so iam trying to get better solution.if you feel this solves your problem ,feel free to contact me , i will give clear syntax.if you have already got better solution than this, please forward to me.
----------------------------------------------------------------------
|
|
|
|