Skip to Main Content

Analytics Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get LAST_VALUE from an Analytic Function within a report?

user10455955Dec 17 2008 — edited Dec 24 2008
My analytical report has following sql:

SELECT....

DENSE_RANK() OVER (PARTITION BY pco.appropriation ORDER BY pco.appropriation,
pco.fiscal_year ASC NULLS LAST) "Duration Years",

SUM(pco.quantity) OVER (PARTITION BY sms.data_source ORDER BY
sms.data_source, cst.display_nm RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT
ROW) "Quantity Cum",

FROM ........

I have a request to calculate the percentage value by dividing MAX or LASTVALUE of these two functions at current row level:_

%DENSE_RANK = LAST_VALUE of ? DENSE_RANK() OVER (PARTITION BY pco.appropriation ORDER BY pco.appropriation,
pco.fiscal_year ASC NULLS LAST) "Duration Years"

/ (divide by)

DENSE_RANK() OVER (PARTITION BY pco.appropriation ORDER BY pco.appropriation,
pco.fiscal_year ASC NULLS LAST) "Duration Years"

%SUM = LAST_VALUE of ? SUM(pco.quantity) OVER (PARTITION BY sms.data_source ORDER BY
sms.data_source, cst.display_nm RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT
ROW) "Quantity Cum",

/ (divide by)

SUM(pco.quantity) OVER (PARTITION BY sms.data_source ORDER BY
sms.data_source, cst.display_nm RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT
ROW) "Quantity Cum"

Example of report output:

DENSE RANK DENSE RANK % SUM SUM %
1 10% 10 10%
2 20% 20 20%
3 100% 30 100%
1 10% 10 10%
2 20% 20 20%
....... ........ ..... ......

I appreciate your help to implement LAST_VALUE function for this case. Many thanks in advance.
Rob.

Edited by: user10455955 on Dec 17, 2008 9:25 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 21 2009
Added on Dec 17 2008
3 comments
703 views