Skip to content
Advertisement

Compare values of timestamps and assign a value to each of them in case they have changed

DB-Fiddle

Expected Result:

In the above result I want to list all products from the table and compare the two time_stamps to each other.
If the plan_week of one product has switched between the both time_stamps I want that in the additional column called week_switch the word yes gets inserted and if not the word no gets inserted.

I tried to go with this query but could not make it work:

What do I need to change to get the expected result?

Advertisement

Answer

I would just use window functions:

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