We are facing issue in converting the Oracle LAG function in the Oracle query to TD. How can we replicate the functionality of Oracle LAG function in TD?
Reference to the Oracle LAG function - http://www.techonthenet.com/oracle/functions/lag.php
Oracle SQL code using LAG function - lag(queried_mpn) OVER( ORDER BY queried_mpn)
Need to resolve it immediately as project is going live next week and this is a showstopper.
Thanks in advance
LAG/LEAD is just a short-cut:
LAG(col,x,val) OVER (ORDER BY col2)
OVER (ORDER BY col2
ROWS BETWEEN x PRECEDING AND x PRECEDING)
For LEAD replace PRECEDING with FOLLOWING.
Thanks for the quick response.
I have tried using the below TD equivalent function for LAG function but the data is not matching exactly (row by row) from Oracle and TD query. Any reason why? Is there any constraint in using the above solution.