Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Get previous column vale till it reaches another not null value - response (1) by VBurmist

$
0
0

 
 
select m.empno, m.eff_dt, p.type_cd
from 
       main as m
 LEFT OUTER JOIN
 (
select empno,
             eff_dt as start_dt,
             coalesce (max(eff_dt) over (partition by empno order by eff_dt rows between 1 following and 1 following) - 1
             , date '9999-12-31') as end_dt,
             type_cd
      from lkp
  )  as p
  ON m.empno = p.empno
    and m.eff_dt between p.start_dt and p.end_dt
order by 1,2


Viewing all articles
Browse latest Browse all 14773

Trending Articles