PC Review


Reply
Thread Tools Rate Thread

Retrieving record with most recent date/time stamp and storing the latest value

 
 
Dan Russotto
Guest
Posts: n/a
 
      13th Oct 2003
I have a database where I am using a many-to-many
relationship as an audit trail. For example, table 1
stores project information for several projects. Table #3
is a listing of all of the releases that a given project
can be developed towards. Table #2, the join table, keeps
track of which release a project is in, and allows the
user to change the release (in a new record) that a
project is in, because it may have missed its deadlines.
Each one of the records has a date/time stamp as an audit
trail of how a project has changed releases. We would
like to store the most current or latest release either
in a query or a table with table #1. In other words, take
a value from the most recent record of the join table
(table #2), and store it in a field in table #1. If a new
record is adden in table #2, then this value should
update the value in table #1. Any suggestions out there
on how to implement this? Thanks, Dan
 
Reply With Quote
 
 
 
 
A Coyle
Guest
Posts: n/a
 
      13th Oct 2003
Hi
Try this, table and fields should be self explanatory

Query1 (finds max release date for each project):
SELECT t_Project.ProjectName, Max(t_ProjectReleaseJoin.ReleaseDate) AS
MaxOfReleaseDate
FROM t_Project INNER JOIN t_ProjectReleaseJoin ON t_Project.ProjectName =
t_ProjectReleaseJoin.ProjectName
GROUP BY t_Project.ProjectName;

Query2 (returns the record matching the max release date):
SELECT query1.ProjectName, query1.MaxOfReleaseDate,
t_ProjectReleaseJoin.ReleaseNumber
FROM query1 INNER JOIN t_ProjectReleaseJoin ON (query1.ProjectName =
t_ProjectReleaseJoin.ProjectName) AND (query1.MaxOfReleaseDate =
t_ProjectReleaseJoin.ReleaseDate);


regards
A


"Dan Russotto" <(E-Mail Removed)> wrote in message
news:138401c39197$0c680a20$(E-Mail Removed)...
> I have a database where I am using a many-to-many
> relationship as an audit trail. For example, table 1
> stores project information for several projects. Table #3
> is a listing of all of the releases that a given project
> can be developed towards. Table #2, the join table, keeps
> track of which release a project is in, and allows the
> user to change the release (in a new record) that a
> project is in, because it may have missed its deadlines.
> Each one of the records has a date/time stamp as an audit
> trail of how a project has changed releases. We would
> like to store the most current or latest release either
> in a query or a table with table #1. In other words, take
> a value from the most recent record of the join table
> (table #2), and store it in a field in table #1. If a new
> record is adden in table #2, then this value should
> update the value in table #1. Any suggestions out there
> on how to implement this? Thanks, Dan



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query to find the most recent record for each duplicate record Microsoft News Server Microsoft Access Queries 3 14th Jun 2008 12:33 AM
Retrieving the most recent record from each person PKI_Dave Microsoft Access Queries 5 15th Feb 2008 03:56 PM
SQL question: Returning most recent order record (must include record ID) J Miro Microsoft Access Queries 1 8th Feb 2006 05:13 AM
Sum of Most Recent to Most Recent-12 months =?Utf-8?B?T2NlbGxOdXJp?= Microsoft Access Queries 5 4th Jan 2006 03:51 PM
How to retreive the latest (most recent) date on a series of entries of a subtable Francine Microsoft Access Queries 1 27th Aug 2003 02:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:03 AM.