Solved

Help with MS ACCESS Query

Posted on 2012-04-05
2
261 Views
Last Modified: 2012-04-06
It seems to me that i can't figure out simple thing.
I have two tables

table 1 - tblMilestones ( PKMilestoneID-number, ProjectID, MilestoneDate,MilestoneTypeID)
table2 - tblTypesOfMilestones(PKMilestoneTypeID,MilestoneName)

they have one to many relationships based on milestonetypeid.

I need to show The oldest Milestone per project.
But query should output ProjectId, MilestoneName and MilestoneDate

thanks for help.
db-question1.accdb
0
Comment
Question by:maximyshka
2 Comments
 
LVL 1

Expert Comment

by:Michel_Nialon
ID: 37813250
Hello
please try something like this :

select  
   tbl1.ProjectID,
   tbl1.MilestoneDate,
   tbl2.MilestoneName
from
   tblMilestones tbl1,
   tblTypesOfMilestones tbl2
where
   tbl2.PKMilestoneTypeID = tbl1.MilestoneTypeID
   and tbl1.MilestoneDate = (select min(MilestoneDate ) from tblMilestones )

I have nothing to test it here, but it should work
michel
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 37813258
try this


SELECT A.Project_ID, A.MilestoneName,A.Milestone_date
From
(SELECT T1.Project_Id, T2.MilestoneName, T1.Milestone_Date
FROM tblTypesOfMilestones as T2 INNER JOIN tblMilestone as T1 ON T2.Milestonetypeid = T1.Milestonetypeid
) As A
Inner Join
(SELECT T.Project_Id, Min(T.Milestone_Date) AS MinOfMilestone_Date
FROM tblMilestone T
GROUP BY T.Project_Id) as B
On A.Milestone_date=B.MinOfMilestone_Date and A.Project_ID=B.Project_ID
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

856 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