Solved

Return only latest status update in query

Posted on 2014-04-07
3
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 38

Expert Comment

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

Accepted Solution

by:
PortletPaul earned 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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.

719 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