Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 21 Dec 2012 @ 03:29:25 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


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



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023