Hello. I am starter in DB world and I am working with ORACLE DB and have specific problem that I cannot find any sufficient explanaiton on net.
I have table that has columnd (VALID_FROM (date) VALID_UNTIL (date) and COUNT (number))
The VALID FROM is mandatory while VALID_UNTIL is nullable (infinity lets say) and I want to get all intervals (they can overlap and they dont need to overlap) and make them into their repsective non overlapping intervals (and sum all count in nonoverlapping intervals)
This is example of input and output that is correct:
Input:
| VALID FROM | VALID UNTIL | COUNT |
|01/01/2023 | NULL |1 |
|01/10/2023 |19/10/2023 |2 |
|03/10/2023 |12/10/2023 |5 |
Output:
| VALID FROM | VALID UNTIL | COUNT |
|1.1.23 | 30.9.23 |1 |
|1.10.23 | 2.10.23 | 3 |
|3.10.23 | 12.10.23 | 8 |
|13.10.23 | 19.10.23 | 3 |
|20.10.23 | NULL | 1 |
what is the most effieicnet qery to achieve this and how this is by far toughest thing i tried to learn.
periods are nightmere.
Thank you