The logic is as follows:
- if a category repeats (like C1), then:
- for each category, calculate the date difference (DATEDIFF) between "closed at" date of a row with "closed" status and the "opened at" date of the rows with an "open" status.
The objective is to have an extra column to the right, with these values:
Difference (in days)
18 (DATEDIFF(dd,17.09.2021,30.08.2021)
16 (DATEDIFF(dd,15.09.2021,30.08.2021)
N/A (because its status is closed)
N/A (because the category doesn't repeat)
N/A (because the category doesn't repeat)
Suggestions?