Need help on using analytical function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • desertrose2908
    New Member
    • Mar 2008
    • 1

    Need help on using analytical function

    Hi ,

    Please help me with this ..

    I have a HEALTHISSUE_AUD IT table which looks like this :

    UPDATEDATE ISSUEID HEALTHINDEX
    1-Mar-08 1 5
    1-Mar-08 2 6
    2-Mar-08 1 7
    2-Mar-08 3 9
    3-Mar-08 2 8
    5-Mar-08 4 2

    I need to get a cumulative sum of the latest value of HEALTHINDEX column per UPDATEDATE.The cumulative sum per UPDATEDATE shud
    1)contain the HEALTHINDEX values ( which is tied to a ISSUEID) for that UPDATEDATE
    2)contain the HEALTHINDEX values , for UPDATEDATE lesser than the current UPDATEDATE
    3)But , if a ISSUEID has already been considered as in point 1, and the same ISSUEID is present in the lesser UPDATEDATE , the cumulative sum must not include this value of HEALTHINDEX , ie , only the latest value of HEALTHINDEX per ISSUEID shud be considered per UPDATEDATE .

    I googled and managed to frame a query like :
    [code=oracle]
    select UPDATEDATE,SUM( SUM(HEALTH_INDE X)) OVER (ORDER BY UPDATEDATE ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumulative_sum from HEALTHISSUE_AUD IT where ISSUEID IN (1,2,3,4) GROUP BY UPDATEDATE ORDER BY UPDATEDATE
    [/code]

    But , this query , also adds , in the cumulative sum the HEALTHINDEX for a repeating ISSUEID.

    Is there a way to not add the duplicate ISSUEID ?

    Thanks in advance
    Last edited by amitpatel66; Mar 27 '08, 04:27 AM. Reason: code tags
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Can you please post the sample output that you got when you executed the above query?

    Comment

    Working...