Monday, November 22, 2010

JD Edwards : Sales count by year/month and search type

select
datepart(yy,DATEADD(dy, cast(SDTRDJ as varchar(10)) % 1000, DATEADD(yy, cast(SDTRDJ as varchar(10)) / 1000,-1)) ),
datepart(mm,DATEADD(dy, cast(SDTRDJ as varchar(10)) % 1000, DATEADD(yy, cast(SDTRDJ as varchar(10)) / 1000,-1)) ),
abat1,count(*) from sales_f4211_f42119 --(union f4211/f42119)
left outer join proddta.f0101 on sdshan=aban8
where sddcto='SO' and sdnxtr=999 and sdlttr<>980
group by abat1,
datepart(yy,DATEADD(dy, cast(SDTRDJ as varchar(10)) % 1000, DATEADD(yy, cast(SDTRDJ as varchar(10)) / 1000,-1)) ),
datepart(mm,DATEADD(dy, cast(SDTRDJ as varchar(10)) % 1000, DATEADD(yy, cast(SDTRDJ as varchar(10)) / 1000,-1)) )

No comments: