• To close to bedtime to code and test, but you should just be able to use the LAG and LEAD operations in a cte to look at the previous [price] and the next [date from] values. Use OVER(ORDER BY [Date From])

    Filter out rows where price = lagprice. They don't change the price so they are irrelevant.

    [Date To] is recalculated by subtracting one day from the LEAD(Date From]) That way there are no gaps in the date ranges.

    Hope this helps.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills