Search code examples
teradatateradata-asteraster

Extract data in Aster Teradata?


i have a time series data like the above one. T0,T1,… represents the Date on which a ticket has been submitted to stage 1, stage 2 and so on.. All i need to do is find the time spent in each stage, provided that following all the stages is not compulsory (i.e. a ticket can move directly from stage 1 to stage 3, and then the date in T2 will be left blank). I need to find the result in Aster Teradata. enter image description here


Solution

  • If you want the difference between stage_n and the next NOT NULL stage:

    LEAST(T1,T2,T3,T4,T5) - T0 AS stage_0,
    LEAST(T2,T3,T4,T5) - T1 AS stage_1,
    LEAST(T3,T4,T5) - T2 AS stage_2,
    LEAST(T4,T5) - T3 AS stage_3,
    T5 - T4 AS stage_4,