on 07-13-2010 9:43 PM
Hello Experts,
I would like to pull all Open Sales Orders that do not have purchase orders and are more than 180 days old.
I tried the following query but does not seems to work exactly:
select t0.DocNum
,t0.DocDate
,DateAdd(Day,180,t0.DocDate) as Due180Days
, t0.DocDueDate
, t1.PymntGroup
, t0.OwnerCode
, t2.firstName
, t2.lastName from ordr t0
inner join OCTG t1 on t0.GroupNum = t1.GroupNum
inner join OHEM t2 on t0.OwnerCode = t2.empID
where (t1.PymntGroup like '%prepaid%'
or t1.PymntGroup like '%deposit%')
and t0.DocStatus ='O'and t0.PoPrss='N' and DATEADD(Day,180,t0.DocDate)>180
and t0.OwnerCode=18
Any hlep would be appreciated.
Regards,
Praneeth
Hello Praneeth,
You may try this:
select t0.DocNum,t0.DocDate,DateAdd(Day,180,t0.DocDate) as Due180Days,
t0.DocDueDate, t1.PymntGroup, t0.OwnerCode, t2.firstName, t2.lastName
from ordr t0
inner join OCTG t1 on t0.GroupNum = t1.GroupNum
inner join OHEM t2 on t0.OwnerCode = t2.empID
where (t1.PymntGroup like '%prepaid%'
or t1.PymntGroup like '%deposit%')
and t0.DocStatus ='O'and t0.PoPrss='N' and DATEDIFF(DD,t0.DocDate,GetDate())>180
and t0.OwnerCode=18
What is exactly the issue not seems to work?
Thanks,
Gordon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
100 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.