Monday, February 16, 2009

Last 5 Received date in Item ledger F4111 JD Edwards



drop table jde_rk.dbo.max250date
select distinct illitm,ilmcu,max(iltrdj)iltrdj into jde_rk.dbo.max250date from proddta.f4111
where ildcto in('oh','ot') and ildct='ov' and ilkcoo=250 --and illitm='1618687'
group by illitm,ilmcu
order by iltrdj

drop table jde_rk.dbo.max250date1
select a.illitm,a.ilmcu, max(b.iltrdj)iltrdj into jde_rk.dbo.max250date1 from proddta.f4111 b
left outer join jde_rk.dbo.max250date a on a.illitm=b.illitm and a.ilmcu=b.ilmcu
where a.iltrdj >b.iltrdj
group by a.illitm,a.ilmcu
order by iltrdj desc

drop table jde_rk.dbo.max250date2
select a.illitm,a.ilmcu, max(b.iltrdj)iltrdj into jde_rk.dbo.max250date2 from proddta.f4111 b
left outer join jde_rk.dbo.max250date1 a on a.illitm=b.illitm and a.ilmcu=b.ilmcu
where a.iltrdj >b.iltrdj
group by a.illitm,a.ilmcu
order by iltrdj desc

drop table jde_rk.dbo.max250date3
select a.illitm,a.ilmcu, max(b.iltrdj)iltrdj into jde_rk.dbo.max250date3 from proddta.f4111 b
left outer join jde_rk.dbo.max250date2 a on a.illitm=b.illitm and a.ilmcu=b.ilmcu
where a.iltrdj >b.iltrdj
group by a.illitm,a.ilmcu
order by iltrdj desc

drop table jde_rk.dbo.max250date4
select a.illitm,a.ilmcu, max(b.iltrdj)iltrdj into jde_rk.dbo.max250date4 from proddta.f4111 b
left outer join jde_rk.dbo.max250date3 a on a.illitm=b.illitm and a.ilmcu=b.ilmcu
where a.iltrdj >b.iltrdj
group by a.illitm,a.ilmcu
order by iltrdj desc

No comments: