This is the schema of the data
select BookingID,UnitID,ProjectID,DueFrom,ScheduledDueID,ROW_NUMBER() OVER (ORDER BY ScheduledDueID DESC) AS ID, CASE