Hi all,
I have a log table and I want to calculate the difference in microseconds between the current record and the previous record, but I'm doing something wrong, so when I try to made the timestampdiff between the timestamp of the current record and the result of lag function I receive the SqlCode : SQL0182.
To explain me better I made this little sample:
Could you help me?
Many thanks.
Bye
I have a log table and I want to calculate the difference in microseconds between the current record and the previous record, but I'm doing something wrong, so when I try to made the timestampdiff between the timestamp of the current record and the result of lag function I receive the SqlCode : SQL0182.
To explain me better I made this little sample:
Code:
Declare Global Temporary Table Testlag (Datetime Timestamp, Test Varchar(50)) ; Insert into TestLag values (current timestamp, 'TEST 1'), (current timestamp + 100 microseconds, 'TEST 2'), (current timestamp + 200 microseconds, 'TEST 3'); Select * From Testlag; Select Datetime, TimestampDiff(1, char(datetime - Lag (Datetime, 1, Datetime) Ignore Nulls Over (Order By Datetime))), Test From Testlag;
Many thanks.
Bye
Comment