Skip to content
Advertisement

How to get previous rows date in SQL?

I have a table that stores the effective date column in order. In some cases as mentioned below I effective date is NULL so in that case I am supposed to pick date from previous column and add 1 day and show as effective date. It works fine when there is a date in previous row but when 2 or more consecutive rows are NULL it doesn’t work.

Advertisement

Answer

Hmmm . . . I think a MAX() does what you want with ROW_NUMBER():

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement