Sql Sybase Ase Alternative Way to Support Lead/Lag Function
There is audit trial requirement that need to be captured into log table these day. But we suffer from the limited function provided by Sybase ASE DB in order to achieve our goals. SybaseASE 12.5 does not support neither analytic function nor row number column, and therefore we have to implement cross comparison by ourselves via basic semantics.
1
2
3
4
5
6
7
8
9
10
11
--create rownum column
select rownum = identity(10), * from #temp_table fromtablewhere1=2
insertinto #temp_table
select * fromtablewhere pid = @pid
insertinto #temp_table
select * from table_history where pid = @pid orderby audit_update_date desc