I am making a very simple activity tracking app. There are 2 main tables, Issues & Status. There are many Status updates for each Issue. There are lookup tables for the Environment, Project, State and Worker fields but I'm not concerned about that part right now.
Issues Table:
IssuesID, AutoNumber
Issue, Text
Environment, Number
Project, Number
Created, Date/Time
State, Number
Status Table:
StatusID, AutoNumber
Issue, Number
Worker, Number
Next Step, Text
Last Status, Date/Time
Last Communication, Memo
Resolution, Memo
I need a query that includes all fields of both tables. I want to select Issues by “State” (that's not included in this query yet), but include only the most recent status (Status.[Last Status]). Basically I want to populate a table with all open issues, but only one row per issue, showing only the most recent status update of each one.
Here is what I’ve got so far. I think it is close but it is not quite working. When I try to run the query it pops up a window asking for the value of t2.StatusID. Since I'm expecting it to select from all StatusIDs using my criteria, I am not sure why it is asking me to supply a value.
SELECT Status.StatusID AS Expr1, Status.Issue AS Expr2, t3.IssuesID, t3.Environment, t3.Project, t3.Created, t3.State, Status.Worker AS Expr3, Status.[Next Step] AS Expr4, Status.[Last Status] AS Expr5, Status.[Last Communication] AS Expr6, Status.Resolution AS Expr7
FROM Status AS t1, Issues AS t3
WHERE Status.[Issue]=t3.IssuesID AND ([Status].[Last Status])=(SELECT Max(t2.[Last Status])
FROM Status t2
WHERE t2.StatusID=t1.StatusID
GROUP BY t2.StatusID);
Issues Table:
IssuesID, AutoNumber
Issue, Text
Environment, Number
Project, Number
Created, Date/Time
State, Number
Status Table:
StatusID, AutoNumber
Issue, Number
Worker, Number
Next Step, Text
Last Status, Date/Time
Last Communication, Memo
Resolution, Memo
I need a query that includes all fields of both tables. I want to select Issues by “State” (that's not included in this query yet), but include only the most recent status (Status.[Last Status]). Basically I want to populate a table with all open issues, but only one row per issue, showing only the most recent status update of each one.
Here is what I’ve got so far. I think it is close but it is not quite working. When I try to run the query it pops up a window asking for the value of t2.StatusID. Since I'm expecting it to select from all StatusIDs using my criteria, I am not sure why it is asking me to supply a value.
SELECT Status.StatusID AS Expr1, Status.Issue AS Expr2, t3.IssuesID, t3.Environment, t3.Project, t3.Created, t3.State, Status.Worker AS Expr3, Status.[Next Step] AS Expr4, Status.[Last Status] AS Expr5, Status.[Last Communication] AS Expr6, Status.Resolution AS Expr7
FROM Status AS t1, Issues AS t3
WHERE Status.[Issue]=t3.IssuesID AND ([Status].[Last Status])=(SELECT Max(t2.[Last Status])
FROM Status t2
WHERE t2.StatusID=t1.StatusID
GROUP BY t2.StatusID);