Calculating REP Differences With Sybase Limitations.
We have table SAMPLE in Sybase. Need to calculate REP difference between current & previous date for same SECURITY_ID. SQL solution complicated due to lack of window functions. esProc SPL makes it easy with direct support for ordered sets.
We have table SAMPLE in the Sybase database. The data is as follows: We are trying to calculate the difference of each REP value and its previous one and display values in the original order of the source table. Below is the desired result: In the original order, calculate the difference between REP on the current date and REP on the previous date for the same SECURITY_ID. SQL written in Sybase: SELECT SECURITY_ID, DATE, REP, REP - PREV_REP AS DIFF FROM ( SELECT T1.SECURITY_ID, T1.DATE, T1.REP , COALESCE(T2.REP, 0) AS PREV_REP FROM SAMPLE T1 ...