D
Dana F. Brewer
I want to be able to list the most current date an item is checked out. As I
was working through the query I used max as an aggregate function but I still
can't get the simple result I want. I'd rather list the fields I have chosen
and somehow select just the most current checkout date. Any help would be
greatly appreciated. Here is my query:
SELECT tblTerritory.TerritoryID, [TerritoryName] & " " &
[TerritoryDescription] AS Description, tblTerritory.TerritoryTypeID,
tblTerritoryType.TerritoryType, Max(tblTerritoryCheckout.DateCheckedOut) AS
CheckedOut, tblTerritoryCheckout.DateCheckedIn AS CheckedIn,
tblTerritoryCheckout.PublisherID, tblPublisher.PublisherName,
tblTerritory.LastUpdate, tblTerritory.UserID, tblTerritory.Notes,
tblTerritory.[Active?], tblTerritory.TerritoryName,
tblTerritory.TerritoryNumber
FROM (((tblTerritory LEFT JOIN tblTerritoryCheckout ON
tblTerritory.TerritoryID=tblTerritoryCheckout.TerritoryID) LEFT JOIN
tblPublisher ON tblTerritoryCheckout.PublisherID=tblPublisher.PublisherID)
INNER JOIN tblTerritoryType ON
tblTerritory.TerritoryTypeID=tblTerritoryType.TerritoryTypeID) INNER JOIN
tblCongregation ON tblTerritory.CongregationID=tblCongregation.CongregationID
GROUP BY tblTerritory.TerritoryID, [TerritoryName] & " " &
[TerritoryDescription], tblTerritory.TerritoryTypeID,
tblTerritoryType.TerritoryType, tblTerritoryCheckout.DateCheckedIn,
tblTerritoryCheckout.PublisherID, tblPublisher.PublisherName,
tblTerritory.LastUpdate, tblTerritory.UserID, tblTerritory.Notes,
tblTerritory.[Active?], tblTerritory.TerritoryName,
tblTerritory.TerritoryNumber, tblCongregation.CongregationName
HAVING (((tblTerritory.TerritoryTypeID) In (1,4)) AND
((tblTerritory.[Active?])=-1) AND ((tblCongregation.CongregationName) Like
[Enter the congregation name:] & "*"))
ORDER BY tblTerritory.TerritoryName, tblTerritory.TerritoryNumber;
....Dana![Smile :-) :-)](/styles/default/custom/smilies/smile.gif)
was working through the query I used max as an aggregate function but I still
can't get the simple result I want. I'd rather list the fields I have chosen
and somehow select just the most current checkout date. Any help would be
greatly appreciated. Here is my query:
SELECT tblTerritory.TerritoryID, [TerritoryName] & " " &
[TerritoryDescription] AS Description, tblTerritory.TerritoryTypeID,
tblTerritoryType.TerritoryType, Max(tblTerritoryCheckout.DateCheckedOut) AS
CheckedOut, tblTerritoryCheckout.DateCheckedIn AS CheckedIn,
tblTerritoryCheckout.PublisherID, tblPublisher.PublisherName,
tblTerritory.LastUpdate, tblTerritory.UserID, tblTerritory.Notes,
tblTerritory.[Active?], tblTerritory.TerritoryName,
tblTerritory.TerritoryNumber
FROM (((tblTerritory LEFT JOIN tblTerritoryCheckout ON
tblTerritory.TerritoryID=tblTerritoryCheckout.TerritoryID) LEFT JOIN
tblPublisher ON tblTerritoryCheckout.PublisherID=tblPublisher.PublisherID)
INNER JOIN tblTerritoryType ON
tblTerritory.TerritoryTypeID=tblTerritoryType.TerritoryTypeID) INNER JOIN
tblCongregation ON tblTerritory.CongregationID=tblCongregation.CongregationID
GROUP BY tblTerritory.TerritoryID, [TerritoryName] & " " &
[TerritoryDescription], tblTerritory.TerritoryTypeID,
tblTerritoryType.TerritoryType, tblTerritoryCheckout.DateCheckedIn,
tblTerritoryCheckout.PublisherID, tblPublisher.PublisherName,
tblTerritory.LastUpdate, tblTerritory.UserID, tblTerritory.Notes,
tblTerritory.[Active?], tblTerritory.TerritoryName,
tblTerritory.TerritoryNumber, tblCongregation.CongregationName
HAVING (((tblTerritory.TerritoryTypeID) In (1,4)) AND
((tblTerritory.[Active?])=-1) AND ((tblCongregation.CongregationName) Like
[Enter the congregation name:] & "*"))
ORDER BY tblTerritory.TerritoryName, tblTerritory.TerritoryNumber;
....Dana
![Smile :-) :-)](/styles/default/custom/smilies/smile.gif)