S
Sean
I was given this query (see below) but it is not doing what I needed. Can
someone please help?
My table = Recv, Fields = TXN, Material, Rdate, Rtime
I want to capture all Materials with a 101 TXN type (each one has a date and
time associated with it) and then I want to see the very next 311 Txn for the
same Material. Usually there is only 1, 101 TXN per material for the same
date, but there can be multiple 311 TXN for that material.
In my work, a 101 TXN shows the date and time a material was received at my
warehouse, and the 311 TXN is when that material was put away and ready for
use. Can someone assist?
Here is a sample set of data
TXN Material RDate RTime
101 Y10238 10/08/08 07:43:29
311 Y10238 10/08/08 09:20:37
311 Y10238 10/08/08 9:45:38
101 Y10238 10/10/08 12:33:17
311 Y10238 10/10/08 12:51:00
101 Y10238 11/05/08 10:12:16
311 Y10238 11/05/08 10:48:34
SELECT s.txn, s.material, min(s.rdate) AS Thedate
FROM recv AS s INNER JOIN (select temp.txn, temp.material, temp.rdate
from recv as Temp
where txn = "101") AS Q ON (s.rdate > q.rdate) AND (s.material = q.material)
AND (s.txn = q.txn)
GROUP BY s.txn, s.material;
someone please help?
My table = Recv, Fields = TXN, Material, Rdate, Rtime
I want to capture all Materials with a 101 TXN type (each one has a date and
time associated with it) and then I want to see the very next 311 Txn for the
same Material. Usually there is only 1, 101 TXN per material for the same
date, but there can be multiple 311 TXN for that material.
In my work, a 101 TXN shows the date and time a material was received at my
warehouse, and the 311 TXN is when that material was put away and ready for
use. Can someone assist?
Here is a sample set of data
TXN Material RDate RTime
101 Y10238 10/08/08 07:43:29
311 Y10238 10/08/08 09:20:37
311 Y10238 10/08/08 9:45:38
101 Y10238 10/10/08 12:33:17
311 Y10238 10/10/08 12:51:00
101 Y10238 11/05/08 10:12:16
311 Y10238 11/05/08 10:48:34
SELECT s.txn, s.material, min(s.rdate) AS Thedate
FROM recv AS s INNER JOIN (select temp.txn, temp.material, temp.rdate
from recv as Temp
where txn = "101") AS Q ON (s.rdate > q.rdate) AND (s.material = q.material)
AND (s.txn = q.txn)
GROUP BY s.txn, s.material;