D
DawnTreader
Hello All
I havent posted in a while since the microsoft groups went offline. :
( I really prefered those groups to the microsoft answers forums, but
i am now stuck with getting my help from elsewhere. just like
microsoft to screw up a good thing.
anyways. on to the reason i post.
i have a set of data that is proving a problem to wrangle. i have a
table where i store a customer order number COID and a DateRequested
record. what this table is meant to do is to record when a request was
made to ship an order. this works well. users input the data. not a
problem.
i have another set of data that stores the information around the
actual act of shipping the orders. this data is stored in 2 tables.
packlist and packlist lines.
i have yet another set of data that stores the invoice information.
this data is stored in 2 tables as well. invoice and invoice lines.
there is a third set of data that i dont believe i need to make part
of this query but it relates to the actual customer order. this is
also stored in 2 tables. customer order and customer order lines. at
one point i had the customer orders in there, but in an attempt to get
better results i removed it.
what we are trying to get out of all this information is the amount of
time from a request to ship an order and the time it actually ships.
so here is the current SQL:
SELECT
tblOrderRequests.VisualOrderID,
dbo_RECEIVABLE_LINE.INVOICE_ID,
dbo_RECEIVABLE_LINE.PACKLIST_ID,
Sum([dbo_RECEIVABLE_LINE]![AMOUNT]*[dbo_RECEIVABLE]![SELL_RATE]) AS
Invoiced_Amount,
Year([INVOICE_DATE]) AS [Year Invoiced],
tblOrderRequests.DateRequested,
dbo_SHIPPER.SHIPPED_DATE,
dbo_RECEIVABLE.INVOICE_DATE,
DateDiff("d",[DateRequested],[SHIPPED_DATE]) AS DaysDiff,
DateDiff("d",[SHIPPED_DATE],[INVOICE_DATE]) AS DaysDiffStI
FROM
((tblOrderRequests
LEFT JOIN ((dbo_RECEIVABLE_LINE LEFT JOIN dbo_RECEIVABLE
ON dbo_RECEIVABLE_LINE.INVOICE_ID = dbo_RECEIVABLE.INVOICE_ID)
LEFT JOIN qryAftermarketSalesPersonnel
ON dbo_RECEIVABLE.SALESREP_ID =
qryAftermarketSalesPersonnel.VisualOrderName)
ON tblOrderRequests.VisualOrderID =
dbo_RECEIVABLE_LINE.CUST_ORDER_ID)
LEFT JOIN dbo_SHIPPER_LINE
ON (dbo_RECEIVABLE_LINE.PACKLIST_ID =
dbo_SHIPPER_LINE.PACKLIST_ID)
AND (dbo_RECEIVABLE_LINE.PACKLIST_LINE_NO =
dbo_SHIPPER_LINE.LINE_NO))
LEFT JOIN dbo_SHIPPER
ON dbo_SHIPPER_LINE.PACKLIST_ID = dbo_SHIPPER.PACKLIST_ID
WHERE
(((Year([SHIPPED_DATE]))=Year(Date()))
AND ((tblOrderRequests.VisualOrderID)="91237"))
OR (((Year([SHIPPED_DATE]))=Year(Date()))
AND ((tblOrderRequests.VisualOrderID)="91237")
AND ((qryAftermarketSalesPersonnel.AftermarketSales)=True))
GROUP BY
tblOrderRequests.VisualOrderID,
dbo_RECEIVABLE_LINE.INVOICE_ID,
dbo_RECEIVABLE_LINE.PACKLIST_ID,
tblOrderRequests.DateRequested,
dbo_SHIPPER.SHIPPED_DATE,
dbo_RECEIVABLE.INVOICE_DATE,
DateDiff("d",[DateRequested],[SHIPPED_DATE]),
DateDiff("d",[SHIPPED_DATE],[INVOICE_DATE])
ORDER BY
tblOrderRequests.VisualOrderID,
dbo_RECEIVABLE_LINE.INVOICE_ID;
note that for the moment i am trying to get just one order to turn out
the way i want it, then i would remove the 91237 criteria and run it
on everything.
here is the resulting data:
COID InvID PackID Amount DateRequest ShipDATE InvDATE
DaysDiff DaysDiffStI
91237 34561 34271 $107.37 2010/06/21 2010/06/15 2010/Jun/15
-6 0
91237 34561 34271 $107.37 2010/06/14 2010/06/15 2010/Jun/15
1 0
91237 34621 34315 $946.81 2010/06/21 2010/06/22 2010/Jun/22
1 0
91237 34621 34315 $946.81 2010/06/14 2010/06/22 2010/Jun/22
8 0
i have shorted the field names for clarity in a list format, hopefully
that sticks when i actually post.
notice that because there were 2 shipments and 2 requests per the one
order i get multiples that are untrue. it should look like this:
COID InvID PackID Amount DateRequest ShipDATE InvDATE
DaysDiff DaysDiffStI
91237 34561 34271 $107.37 2010/06/14 2010/06/15 2010/Jun/15
1 0
91237 34621 34315 $946.81 2010/06/21 2010/06/22 2010/Jun/22
1 0
is there a way to achieve this? no matter what i do i get multiples
per each request and shipment. i was thinking that if i could use the
request date as criteria i could get a between date critera and use
that to match up the first request with the first shipment and the
second request with the second shipment. but then how do i tell the
criteria to take the first date against the shipped date?
if anyone can help please do.
as always any and all help appreciated.
I havent posted in a while since the microsoft groups went offline. :
( I really prefered those groups to the microsoft answers forums, but
i am now stuck with getting my help from elsewhere. just like
microsoft to screw up a good thing.
anyways. on to the reason i post.
i have a set of data that is proving a problem to wrangle. i have a
table where i store a customer order number COID and a DateRequested
record. what this table is meant to do is to record when a request was
made to ship an order. this works well. users input the data. not a
problem.
i have another set of data that stores the information around the
actual act of shipping the orders. this data is stored in 2 tables.
packlist and packlist lines.
i have yet another set of data that stores the invoice information.
this data is stored in 2 tables as well. invoice and invoice lines.
there is a third set of data that i dont believe i need to make part
of this query but it relates to the actual customer order. this is
also stored in 2 tables. customer order and customer order lines. at
one point i had the customer orders in there, but in an attempt to get
better results i removed it.
what we are trying to get out of all this information is the amount of
time from a request to ship an order and the time it actually ships.
so here is the current SQL:
SELECT
tblOrderRequests.VisualOrderID,
dbo_RECEIVABLE_LINE.INVOICE_ID,
dbo_RECEIVABLE_LINE.PACKLIST_ID,
Sum([dbo_RECEIVABLE_LINE]![AMOUNT]*[dbo_RECEIVABLE]![SELL_RATE]) AS
Invoiced_Amount,
Year([INVOICE_DATE]) AS [Year Invoiced],
tblOrderRequests.DateRequested,
dbo_SHIPPER.SHIPPED_DATE,
dbo_RECEIVABLE.INVOICE_DATE,
DateDiff("d",[DateRequested],[SHIPPED_DATE]) AS DaysDiff,
DateDiff("d",[SHIPPED_DATE],[INVOICE_DATE]) AS DaysDiffStI
FROM
((tblOrderRequests
LEFT JOIN ((dbo_RECEIVABLE_LINE LEFT JOIN dbo_RECEIVABLE
ON dbo_RECEIVABLE_LINE.INVOICE_ID = dbo_RECEIVABLE.INVOICE_ID)
LEFT JOIN qryAftermarketSalesPersonnel
ON dbo_RECEIVABLE.SALESREP_ID =
qryAftermarketSalesPersonnel.VisualOrderName)
ON tblOrderRequests.VisualOrderID =
dbo_RECEIVABLE_LINE.CUST_ORDER_ID)
LEFT JOIN dbo_SHIPPER_LINE
ON (dbo_RECEIVABLE_LINE.PACKLIST_ID =
dbo_SHIPPER_LINE.PACKLIST_ID)
AND (dbo_RECEIVABLE_LINE.PACKLIST_LINE_NO =
dbo_SHIPPER_LINE.LINE_NO))
LEFT JOIN dbo_SHIPPER
ON dbo_SHIPPER_LINE.PACKLIST_ID = dbo_SHIPPER.PACKLIST_ID
WHERE
(((Year([SHIPPED_DATE]))=Year(Date()))
AND ((tblOrderRequests.VisualOrderID)="91237"))
OR (((Year([SHIPPED_DATE]))=Year(Date()))
AND ((tblOrderRequests.VisualOrderID)="91237")
AND ((qryAftermarketSalesPersonnel.AftermarketSales)=True))
GROUP BY
tblOrderRequests.VisualOrderID,
dbo_RECEIVABLE_LINE.INVOICE_ID,
dbo_RECEIVABLE_LINE.PACKLIST_ID,
tblOrderRequests.DateRequested,
dbo_SHIPPER.SHIPPED_DATE,
dbo_RECEIVABLE.INVOICE_DATE,
DateDiff("d",[DateRequested],[SHIPPED_DATE]),
DateDiff("d",[SHIPPED_DATE],[INVOICE_DATE])
ORDER BY
tblOrderRequests.VisualOrderID,
dbo_RECEIVABLE_LINE.INVOICE_ID;
note that for the moment i am trying to get just one order to turn out
the way i want it, then i would remove the 91237 criteria and run it
on everything.
here is the resulting data:
COID InvID PackID Amount DateRequest ShipDATE InvDATE
DaysDiff DaysDiffStI
91237 34561 34271 $107.37 2010/06/21 2010/06/15 2010/Jun/15
-6 0
91237 34561 34271 $107.37 2010/06/14 2010/06/15 2010/Jun/15
1 0
91237 34621 34315 $946.81 2010/06/21 2010/06/22 2010/Jun/22
1 0
91237 34621 34315 $946.81 2010/06/14 2010/06/22 2010/Jun/22
8 0
i have shorted the field names for clarity in a list format, hopefully
that sticks when i actually post.
notice that because there were 2 shipments and 2 requests per the one
order i get multiples that are untrue. it should look like this:
COID InvID PackID Amount DateRequest ShipDATE InvDATE
DaysDiff DaysDiffStI
91237 34561 34271 $107.37 2010/06/14 2010/06/15 2010/Jun/15
1 0
91237 34621 34315 $946.81 2010/06/21 2010/06/22 2010/Jun/22
1 0
is there a way to achieve this? no matter what i do i get multiples
per each request and shipment. i was thinking that if i could use the
request date as criteria i could get a between date critera and use
that to match up the first request with the first shipment and the
second request with the second shipment. but then how do i tell the
criteria to take the first date against the shipped date?
if anyone can help please do.
as always any and all help appreciated.