Calculating MAX(DATE) for Value Groups Where Values Go Back and Forth

有些话、适合烂在心里 提交于 2020-01-06 13:54:22

问题


I have another challenge that I am trying to resolve but unable to get the solution yet. Here is the scenario. Pardon the formatting if it messes up at the time of posting.

  ACCT_NUM  CERT_ID  Code    Date    Desired Output 
      A        1      10   1/1/2007    1/1/2008 
      A        1      10   1/1/2008    1/1/2008 
      A        1      20   1/1/2009    1/1/2010 
      A        1      20   1/1/2010    1/1/2010 
      A        1      10   1/1/2011    1/1/2012 
      A        1      10   1/1/2012    1/1/2012 
      A        2      20   1/1/2007    1/1/2008 
      A        2      20   1/1/2008    1/1/2008 
      A        2      10   1/1/2009    1/1/2010 
      A        2      10   1/1/2010    1/1/2010 
      A        2      30   1/1/2011    1/1/2011 
      A        2      10   1/1/2012    1/1/2013 
      A        2      10   1/1/2013    1/1/2013 

As you can see, I need to do a MAX on the date based on each group of code values (apart from ACCT_NUM and CERT_ID) before the value changes. If the same value repeats, I need to a MAX of the data again for that group separately. For example, for CERT_ID of '1', I cannot group all four rows of Code 10 to get a MAX date of 1/1/2012. I need to get the MAX for the first two rows and then another MAX for the next two rows separately since there is another code in between. I am trying to accomplish this in Cognos Framework Manager.

Gurus, please advise.


回答1:


The syntax for getting the max value for CERT_ID is:

maximum(Date for CERT_ID)

If you want additional level/s for max you can use the following syntax:

maximum(Date for ACCT_NUM,CERT_ID,Code)

In general, it is best practice to group and summarize values in report, not in framework manager.



来源:https://stackoverflow.com/questions/18475514/calculating-maxdate-for-value-groups-where-values-go-back-and-forth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!