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

x
?
Solved

Help with MS ACCESS Query

Posted on 2012-04-05
2
Medium Priority
?
270 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 2000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
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…

876 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