Skip to content
Advertisement

How to calculate the difference between current row and the last row of last month?

I have a postgres table net_value as above, one row one day.

How can I calculate the difference between current row and the last row of last month? Look like the output as below:

Thanks!

Advertisement

Answer

Hmmm . . . Here is a method with a join:

I also think an approach using window functions and a window frame should also work:

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