Archives of the TeradataForum
Message Posted: Thu, 21 Dec 2012 @ 03:29:25 GMT
Subj: | | Re: Help needed with Lead and Lag functions |
|
From: | | Curley, David |
LEAD & LAG are really just shortcuts to save you some typing. Do it the way you'd do it in Oracle if they didn't exist:
MIN(action_name) OVER (PARTITION BY ID,request_name ORDER BY timestamp_det ROWS BETWEEN 1
FOLLOWING AND 1 FOLLOWING) next_action
MAX(action_name) OVER (PARTITION BY ID,request_name ORDER BY timestamp_det ROWS BETWEEN 1
PRECEDING AND 1 PRECEDING) previous_action
The can use MIN or MAX, I just like doing in that way to show which one is getting the minimum row after and the max row before.
Dave
|