G
Guest
I am attempting to return key records from 2 linked tables based on the
Maximum negative number returned from a DateDiff calculation.
Tables (linked on [Acct])
Table 1: T_Issue Table 2: T_Results
Acct Acct
UnitNo ResultNo
IssueDT CollectDT
Result
This first query returns:
-All [UnitNo] records from the T_Issue table
-The associated [ResultNo] records from the T_Results table where the
DateDiff is a negative number.
-The results of the DateDiff calculation
Qtime
SELECT [T_Issue].[UnitNo], DateDiff("h",[IssueDT],[CollectDT]) AS LabTime,
[Lab Results].[ResultNo]
FROM (([T_Results] RIGHT JOIN [T_Issue] ON [T_Results].Account =
[T_Issue].Account)
WHERE (((DateDiff("h",[IssueDT],[CollectDT]))<0))
ORDER BY [T_Issue].[UnitNo], DateDiff("h",[IssueDT],[CollectDT]) DESC;
The second Query attempts to return the records associated with the Max
[LabTime] calculated field, grouped by [UnitNo].
However, as written, no results are returned. I have also tried to include
the Max and DateDiff in the first Query without success.
Qmax
SELECT Qtime.[UnitNo], Qtime.LabTime, Qtime.[ResultNo]
FROM Qtime
WHERE (((Qtime.LabTime) In (SELECT Max([Qtime].[ResultNo]) AS MaxLabTime
FROM [Qtime]
GROUP BY [Qtime].[UnitNo])));
I sincerely appreciate any help offered.
Maximum negative number returned from a DateDiff calculation.
Tables (linked on [Acct])
Table 1: T_Issue Table 2: T_Results
Acct Acct
UnitNo ResultNo
IssueDT CollectDT
Result
This first query returns:
-All [UnitNo] records from the T_Issue table
-The associated [ResultNo] records from the T_Results table where the
DateDiff is a negative number.
-The results of the DateDiff calculation
Qtime
SELECT [T_Issue].[UnitNo], DateDiff("h",[IssueDT],[CollectDT]) AS LabTime,
[Lab Results].[ResultNo]
FROM (([T_Results] RIGHT JOIN [T_Issue] ON [T_Results].Account =
[T_Issue].Account)
WHERE (((DateDiff("h",[IssueDT],[CollectDT]))<0))
ORDER BY [T_Issue].[UnitNo], DateDiff("h",[IssueDT],[CollectDT]) DESC;
The second Query attempts to return the records associated with the Max
[LabTime] calculated field, grouped by [UnitNo].
However, as written, no results are returned. I have also tried to include
the Max and DateDiff in the first Query without success.
Qmax
SELECT Qtime.[UnitNo], Qtime.LabTime, Qtime.[ResultNo]
FROM Qtime
WHERE (((Qtime.LabTime) In (SELECT Max([Qtime].[ResultNo]) AS MaxLabTime
FROM [Qtime]
GROUP BY [Qtime].[UnitNo])));
I sincerely appreciate any help offered.