I have the following doubt, I have two tables "TEJCRETE" and "CCEPTCPT" and I need to calculate the minutes of difference between FECFIN - FECINI. However, it may be that some dates overlap. That is to say, In the example, only my total minutes for the first two records it should only be 230 minutes and not the sum 555 since the dates They are superimposed.
I would like to know in what way I could do it, if in an SP or using cursors or just a simple query.
I appreciate your help
Note: Consider that for the second FECFIN record the date is: 2018-10-02-00.50.00 and not 2018-10-01-22.55.00