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

Need to calculate using LEAD, LAG function - response (4) by mohan.mscss

$
0
0
Here it is.. sel a.empid as a1, min(b.effdate) as leave_start_date, a.effdate as leave_end_date from     (sel empid,effdate,          coalesce(                 min(effdate)over(partition by empid order by effdate rows between 1 preceding and 1 preceding)                ,cast('1900-01-01'as date)) as n1          from mkdate where emp_stat='ACTIVE'      )a left join      (sel empid,effdate from mkdate where emp_stat='LEAVE')b      on a.empid = b.empid and  a.effdate  >= b.effdate and a.n1 < b.effdate group by 1,3 order by 1,3,2; Regards, Mohan K

Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>