0 votes
Trying to find a simple way to calculate the difference in datetime between rows in a column.  Number of rows in dataset very large therefore pivot will not work.  Where deltadatetime of current row = datetime of next row - datetime of current row by unique ID

{ID]  [DateTime]   [Code]  [DeltaDateTime]
asked by

1 Answer

0 votes

Assuming your IDs are unique in the dataset

You can use a window recipe with the following settings

- order columns: ID

- window frame: limit the number of preceeding (or) following rows = 1

- aggregation -> lag (or lead) diff ( you can choose in seconds up to years) or use a custom aggregation

answered by
821 questions
844 answers
746 users