Results 1 to 3 of 3
  1. #1
    Join Date
    May 2017
    Posts
    1

    Unanswered: Issue Calculating MTD value in DB2 query

    Hi, I have a requirement to perform product of previous rows with current row dynamically every day to calculate the percentage change in pricing value for MTD. For this i have a formula shared which does a product of all daily price percentage each day and calculates MTD. (So Column B is the output format of the value required). ie. Need to multiply each value from Column A daily with all previous values till month start . Basically Need output in below format:


    Column(Date) ColumnA(Price) ColumnB(product)
    D1 P1 P1
    D2 P2 P1*P2
    D3 P3 P1*P2*P3 or (B2*P3)

    and so on...

    Trying to do self joins and not getting desired output, Any help with query in DB2 is appreciated much ! - Thanks Any quick help is appreciated

  2. #2
    Join Date
    May 2010
    Location
    India
    Posts
    90
    Provided Answers: 2
    You can use lag and first_value OLAP functions. See the link for more details about these functions.

    Link: https://www.ibm.com/support/knowledg.../r0023461.html


    Satya...

  3. #3
    Join Date
    Jul 2016
    Location
    Moscow
    Posts
    294
    Provided Answers: 45
    Regards,
    Mark.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •