输入:
ID STATUS YEAR MONTH
A OPEN1 2017-01
A OPEN2 2017-01
A CLOSED 2017-03
B OPEN1 2017-01
B OPEN2 2017-02
B OPEN3 2017-02
B Closed 2017-05
我的输出:
2017-02:
(只有c计数为open1为a& b移动到diff状态)open1
(只有一个计数(从prev月开始),b在open2中)
2017-03:
c在prev月的Open1中
b从prev月count2
开放YEAR MONTH COUNT-OPEN1 COUNT-OPEN2 COUNT-CLOSED
2017-01 2(A&B OPEN1) 1(A IN OPEN1) 0
2017-02 1 2 0
2017-03 1 1 1(A CLOSED)
2017-04 1 0 2(A,B CLOSED)
2017-05 1 0 2
2017-06 1 0 2
2017-07 1 0 2
2017-08 1 0 2
2017-09 1 0 2
我需要将数据添加到以前几个月到接下来几个月的打开/关闭,在不使用光标的情况下,SAP HANA是否可以使用?就像我可以使用光标做的那样,如果存在其他逻辑,请帮助我!
您可以参考此博客,它应该能够帮助您。
https://blogs.sap.com/2014/03/10/how-tocalculate ytd-mtd-mtd-anytd-using-date-date-dimensions/