Home Page for the TeradataForum
 
https:

Archives of the TeradataForum

Message Posted: Tue, 22 Feb 2005 @ 15:26:50 GMT


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


Subj:   Re: Finding previous record puzzle
 
From:   ulrich arndt

Hi,

this will work also:

     create table txn
     ( txn_id integer,
       txn_dt date,
       txn_time time(0)
     ) unique primary index (txn_id);

     insert into  txn values (1234,'2005-02-20','23:15:59');
     insert into  txn values (2134,'2005-02-20','23:45:59');
     insert into  txn values (1122,'2005-02-20','19:35:26');
     insert into  txn values (1245,'2005-02-21','01:23:44');
     insert into  txn values (2014,'2005-02-21','09:19:10');

     select txn_id ,
           txn_dt,
           txn_time
     from  txn
     qualify sum(case when txn_id = 1245 then 1 else 0 end )
     over (order by txn_dt, txn_time
                           rows between 1  following and 1  following
                           ) = 1

Kind regards

Ulrich Arndt

www.data2knowledge.de



     
  <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: 28 Jun 2020