I want the date_end column to iteratively compare the next row and delete it until the date_end is greater than in it. e.g
R| date_end
1| 1993-12-20
2| 1993-11-17
3| 1993-11-17
4| 1993-12-30
5| 1993-12-30
6| 1994-01-21
7| 1993-01-05
I want to store Row 1, 4, 6 in a new temporary table. I have used the self join technique unsuccessfully. There are other column in the table as well.
SELECT
a.*,
b.datestart AS datestart2,
b.hourtimestart AS hourtimestart2,
b.dateend AS dateend2,
b.hourtimeend AS hourtimeend2,
b.Amount AS Amount2,
b.mintime AS mintime2
FROM
tempdb.combined3 a,
tempdb.combined4 b;
SELECT
*
FROM
tempdb.combined5
WHERE
(dateend < datestart2)
ORDER BY datestart , datestart2;

UPDATE: https://www.db-fiddle.com/f/6JCMtaMJvrq9D6vZZFu8xt/2