How to compare current week monday value with previous week monday value ? If there's difference in both it should display the value.
The sample table is : In the below table I want to compare the current week number to the previous week number to check if the values are different. In case 1 (112) current week is 2022/04 and previous week is 2022/03 which has null value in the output table both this value is to be displayed .
Note current week value is according to weekstart today and previous is weekstart today-1.
P Id | P Desc | P Prod | Cycle No | Week No | Value |
112 | asm | 222 | 178 | 2022/2 | PD |
112 | asm | 222 | 178 | 2022/4 | PD |
123 | abc | 222 | 178 | 2022/1 | X |
123 | abc | 222 | 178 | 2022/2 | X |
123 | abc | 222 | 178 | 2022/3 | X |
123 | abc | 222 | 178 | 2022/4 | X |
131 | hah | 222 | 178 | 2022/1 | PD |
131 | hah | 222 | 178 | 2022/2 | PD |
131 | hah | 222 | 178 | 2022/3 | PD |
131 | hah | 222 | 178 | 2022/4 | X |
132 | bvs | 222 | 178 | 2022/1 | X |
132 | bvs | 222 | 178 | 2022/2 | X |
132 | bvs | 222 | 178 | 2022/3 | X |
132 | bvs | 222 | 178 | 2022/4 | X |
Please find the output table. It should only contain data for current and previous week.
Output | |||||
P Id | P Desc | P Prod | Cycle No | Week No | Value |
112 | asm | 222 | 178 | 2022/3 | |
112 | asm | 222 | 178 | 2022/4 | PD |
131 | hah | 222 | 178 | 2022/3 | PD |
131 | hah | 222 | 178 | 2022/4 | X |
How can I achieve this?