Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Return only latest status update in query

Posted on 2014-04-07
3
Medium Priority
?
283 Views
Last Modified: 2014-04-08
Hi.  I am using Access 2010 and trying to create a query that will return only the most recent status update for a project.
Here's the sql for the query.

SELECT DISTINCT qryProjectID.ProjID, tblStatus.StatusDate, Max(tblStatus.StatusDate) AS LatestDate
FROM qryProjectID INNER JOIN tblStatus ON qryProjectID.ProjID = tblStatus.ProjectID
GROUP BY qryProjectID.ProjID, tblStatus.StatusDate;
picture of resultsThis is the result I get.  I want Project 1 only once and showing the last status update date.  Suggestions anyone?

Tables are tblProject with ProjID and tblStatus with ProjectID, StatusID, StatusDate, and other detail fields.  Tables are joined one to many from tblProject to tblStatus.
0
Comment
Question by:esbyrt
3 Comments
 
LVL 40

Expert Comment

by:PatHartman
ID: 39984595
Remove the Distinct predicate.  It is interfering with the grouping.
0
 
LVL 49

Accepted Solution

by:
PortletPaul earned 2000 total points
ID: 39984680
if you want the project just once then remove  tblStatus.StatusDate as a column and in the group by

SELECT qryProjectID.ProjID,  Max(tblStatus.StatusDate) AS LatestDate
FROM qryProjectID INNER JOIN tblStatus ON qryProjectID.ProjID = tblStatus.ProjectID
GROUP BY qryProjectID.ProjID;

ps, never use select distinct when also doing a group by - it's a complete waste of time
0
 

Author Closing Comment

by:esbyrt
ID: 39987241
Worked like a dream!  Thank you!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question