Suppose I have the following table:
start_data | end_date
----------------------
t1 | Null
Null | t2
t3 | Null
Null | t4
t5 | Null
The output should be like this:
start_data | end_date
----------------------
t1 | t2
t3 | t4
t5 | Null
notes:
- the type of ti is date
- ti < ti+1 holds true for all values.
pseudo code:
for every record i
xi <--- start_date
yi <--- end_date
zi <---- min(yi) && xi>yi
(xi,zi) should be the output for this record i
Is it solvable using native SQL?
coalesce(start_data, end_date)or the equivalent in the OP's DBMS of choice, which he sadly failed to mention. – mustaccio Nov 20 '18 at 17:48