17
Mar
LAG function in sql is used when we have data based on time and we want to replace the current data from the previous month's data. In Oracle, you could use the LAG function within a case statement like so: If the data looks like this: MONTH | Value ___________________ JAN2016 | 100.00 FEB2016 | MAR2016 | 342.60 APR2016 | 450.20 Code: SELECT MONTH, CASE WHEN Value is null then LAG(Value OVER MONTH,1) else Value END as Value FROM myTable; The result would be: MONTH | Value ________________________ JAN2016 | 100.00 FEB2016 | 100.00 MAR2016 | 342.60 APR2016 | 450.20 This solution will work…