Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 28 Mar 2011 @ 16:23:00 GMT


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


Subj:   Re: Reporting Question
 
From:   Curley, David

SQL Server supports windowed functions, right? I think you'd do it more or less the same way in Teradata, something like:

     Select personalID, topic, ActiveTimeStamp,ReturnTimeStamp, Case when
     min(cast(ActiveTimeStamp as date)) over (partition by PersonalID order by ActiveTimeStamp
     rows between 1 following and 1
     following) between cast(ActiveTimeStamp as Date) and cast(ActiveTimeStamp as
     Date) + 14 then min(Topic) over (partition by PersonalID order by ActiveTimeStamp rows
     between 1 following and 1
     following) else null end NextTopic
     From SomeTable
     Qualify NextTopic is not null

I can't quite figure out exactly what you want - is it each row where the next row for that person has an ActiveTimeStamp w/in 14 days (that's what the above does)? If a PersonalID has > 1 row but none are w/in 14 days of each other, are they included?

Either way, this should get you started.


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