Solved

Help with MS ACCESS Query

Posted on 2012-04-05
2
260 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can you open the FORM2 2 31
How to execute an access 2007 module from vb6 2 35
VBA to copy the database back end to a new database file. 3 34
Access query expression 6 20
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

770 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