Skip to content
Advertisement

logic for subtracting and getting variance in oracle

how to write a logic for getting the below output

i am getting this ouput

but i want the this output

Advertisement

Answer

The issue with your code is, You are using LAG on the CHAR column(PERIOD) which is not correct as 2020-FEB is lower than the 2020-JAN when the comparison is in the string.

You must use them as the date in LAG function as following:

Cheers!!

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