Skip to content
Advertisement

SQL how to get latest date and update every time it occurs (not using MAX)

I’m trying to get the latest date of starting event before it occurs again.

Data I have:

What I want to make:

I want to create another column with the latest start time and record it, then update it whenever it happens, and keep that value from there until start appears again.

What I tried:

This didn’t work since MAX only returns the latest one showing up, which isn’t what I was trying to do:

What would be the right approach here to achieve my goal?

Advertisement

Answer

You almost did it – you just need to add order by clause:

enter image description here

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