Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Need to calculate using LEAD, LAG function - response (5) by Mathuram

$
0
0
Sel emplid,effdt,empl_status, coalesce(mdiff(est,1,rno),-1) cnn from (sel emplid,effdt,empl_status, case empl_status when 'active' then 2 else 1 end est, rank(effdt asc,empl_status) rno from tab1)t qualify cnn in(-1,1) my answerset would be like this 31,750    1/1/2009      LEAVE 31,750    1/23/2009    ACTIVE 31,750    2/1/2009      LEAVE 31,750    2/1/2009      ACTIVE 31,750    6/1/2009      LEAVE 31,750    5/2/2010      ACTIVE 31,750    7/1/2010      LEAVE 31,750    11/1/2011    ACTIVE use the above query to seperate the EFFDT column as per your requirement.  

Viewing all articles
Browse latest Browse all 27759

Trending Articles