D
DawnTreader
i have done a little research in to how to find the max of something that is
related to another table. i have a compressor table that has a running hours
table related to it. i need to find the max running hours
Compressor
compressorID
SerialNumber
etc...
RunningHours
RunninghoursID
Date
HoursAtDate
this allows us to have a history of the running hours. on my forms i want to
show the most current running hours entered, but the query i am setting up to
gather the data for the sub form is showing 2 records for one compressorID
here is the 2 queries i have made.
SELECT subtblRunningHours.CompressorID, Max(subtblRunningHours.Date) AS
MaxOfDate
FROM subtblRunningHours
GROUP BY subtblRunningHours.CompressorID;
this query is used to get the max date. this works fine.
SELECT subtblRunningHours.Date, subtblRunningHours.HoursAtDate,
subtblRunningHours.CompressorID
FROM subqryMaxHours INNER JOIN subtblRunningHours ON
subqryMaxHours.MaxOfDate = subtblRunningHours.Date
GROUP BY subtblRunningHours.Date, subtblRunningHours.HoursAtDate,
subtblRunningHours.CompressorID
ORDER BY subtblRunningHours.Date DESC;
this uses the other query to only pick the dates that match a maxdate to get
the hours.
if anyone can help please do.
related to another table. i have a compressor table that has a running hours
table related to it. i need to find the max running hours
Compressor
compressorID
SerialNumber
etc...
RunningHours
RunninghoursID
Date
HoursAtDate
this allows us to have a history of the running hours. on my forms i want to
show the most current running hours entered, but the query i am setting up to
gather the data for the sub form is showing 2 records for one compressorID
here is the 2 queries i have made.
SELECT subtblRunningHours.CompressorID, Max(subtblRunningHours.Date) AS
MaxOfDate
FROM subtblRunningHours
GROUP BY subtblRunningHours.CompressorID;
this query is used to get the max date. this works fine.
SELECT subtblRunningHours.Date, subtblRunningHours.HoursAtDate,
subtblRunningHours.CompressorID
FROM subqryMaxHours INNER JOIN subtblRunningHours ON
subqryMaxHours.MaxOfDate = subtblRunningHours.Date
GROUP BY subtblRunningHours.Date, subtblRunningHours.HoursAtDate,
subtblRunningHours.CompressorID
ORDER BY subtblRunningHours.Date DESC;
this uses the other query to only pick the dates that match a maxdate to get
the hours.
if anyone can help please do.