Code:SQL> select factory, capacity, demand, actualdemand, backlog, 2 --lag one row behind, return null if nothing found 3 demand + lag(backlog, 1, null) OVER 4 (order by factory) revised_demand 5 from lagdemo order by factory; FACTORY CAPACITY DEMAND ACTUALDEMAND BACKLOG REVISED_DEMAND ---------- ---------- ---------- ------------ ---------- -------------- 1 100 80 80 0 2 50 40 40 0 40 3 100 150 150 50 150 4 30 20 70 40 70 5 80 30 70 0 70 6 100 70 70 0 70




Reply With Quote