Displaying Latest Date Only

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table with several entries for each ID. I want to create a report that lists only the latest info. How do I modify this query to give me only the latest [EditDate] for each [TagName].[RoleName]

SELECT tblTags.TagID, [TagName] & "." & [RoleName] AS TagRole, tblTagSentences.EditDate, tblTagSentences.MaleSentence, tblTagSentences.[Female Sentence
FROM tblRoles INNER JOIN (tblTags INNER JOIN tblTagSentences ON tblTags.TagID = tblTagSentences.TagID) ON tblRoles.RoleID = tblTagSentences.RoleID;
 
SELECT tblTags.TagID, [TagName] & "." & [RoleName] AS TagRole,
tblTagSentences.EditDate, tblTagSentences.MaleSentence,
tblTagSentences.[Female Sentence]
FROM tblRoles INNER JOIN (tblTags INNER JOIN tblTagSentences ON
tblTags.TagID = tblTagSentences.TagID) ON tblRoles.RoleID =
tblTagSentences.RoleID
WHERE tblTagSentences.EditDate =
(SELECT Max(EditDate) FROM tblTagSentences As T2
WHERE T2.TagID = tblTags.TagID AND T2.RoleID = tblRoles.RoleID)

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
Laurie said:
I have a table with several entries for each ID. I want to create a
report that lists only the latest info. How do I modify this query to give
me only the latest [EditDate] for each [TagName].[RoleName]?
SELECT tblTags.TagID, [TagName] & "." & [RoleName] AS TagRole,
tblTagSentences.EditDate, tblTagSentences.MaleSentence,
tblTagSentences.[Female Sentence]
FROM tblRoles INNER JOIN (tblTags INNER JOIN tblTagSentences ON
tblTags.TagID = tblTagSentences.TagID) ON tblRoles.RoleID =
tblTagSentences.RoleID;
 
Worked like a charm. Thank you very much.

-----Original Message-----
SELECT tblTags.TagID, [TagName] & "." & [RoleName] AS TagRole,
tblTagSentences.EditDate, tblTagSentences.MaleSentence,
tblTagSentences.[Female Sentence]
FROM tblRoles INNER JOIN (tblTags INNER JOIN tblTagSentences ON
tblTags.TagID = tblTagSentences.TagID) ON tblRoles.RoleID =
tblTagSentences.RoleID
WHERE tblTagSentences.EditDate =
(SELECT Max(EditDate) FROM tblTagSentences As T2
WHERE T2.TagID = tblTags.TagID AND T2.RoleID = tblRoles.RoleID)

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
news:759B94C4-B8C8-439F-B349-
(e-mail address removed)...
I have a table with several entries for each ID. I
want to create a
report that lists only the latest info. How do I modify this query to give
me only the latest [EditDate] for each [TagName]. [RoleName]?
SELECT tblTags.TagID, [TagName] & "." & [RoleName] AS
TagRole,
tblTagSentences.EditDate, tblTagSentences.MaleSentence,
tblTagSentences.[Female Sentence]
FROM tblRoles INNER JOIN (tblTags INNER JOIN
tblTagSentences ON
tblTags.TagID = tblTagSentences.TagID) ON tblRoles.RoleID =
tblTagSentences.RoleID;


.
 
Back
Top