R
Rayo K
I have my SQL pasted below. I need some help. My table structure is as
follows. There is an Issues table with a primary key "ID" and an Updates
Table with a field for "IssueID" that is linked to "ID" as one-to-many. The
idea is that for each issue we can create many updates taht are all linked to
that issue.
I now want to create a query to generate a report that will list selected
issues, along with the LAST update for each issue. Each update has a
date/time and I am trying to get the MAX date/time of updates for each issue.
However, the remainder of the data is not showing up correctly. (e.g. I will
get the date/time for update 2 but the text from update 1).
I know i am missing something in the query structure but I do not know what.
Please help!!!!
SELECT DISTINCTROW Max(UpdatesQry.Date) AS MaxOfDate,
First(UpdatesQry.Update) AS FirstOfUpdate, UpdatesQry.Final, [All Open Issues
Query].ID, [All Open Issues Query].Priority, [All Open Issues Query].[Date
Entered], [All Open Issues Query].Area, [All Open Issues Query].Department,
[All Open Issues Query].Issue, [All Open Issues Query].Resolution, [All Open
Issues Query].[Date Closed], UpdatesQry.IssueID
FROM [All Open Issues Query] INNER JOIN UpdatesQry ON [All Open Issues
Query].ID = UpdatesQry.IssueID
GROUP BY UpdatesQry.Final, [All Open Issues Query].ID, [All Open Issues
Query].Priority, [All Open Issues Query].[Date Entered], [All Open Issues
Query].Area, [All Open Issues Query].Department, [All Open Issues
Query].Issue, [All Open Issues Query].Resolution, [All Open Issues
Query].[Date Closed], UpdatesQry.IssueID;
follows. There is an Issues table with a primary key "ID" and an Updates
Table with a field for "IssueID" that is linked to "ID" as one-to-many. The
idea is that for each issue we can create many updates taht are all linked to
that issue.
I now want to create a query to generate a report that will list selected
issues, along with the LAST update for each issue. Each update has a
date/time and I am trying to get the MAX date/time of updates for each issue.
However, the remainder of the data is not showing up correctly. (e.g. I will
get the date/time for update 2 but the text from update 1).
I know i am missing something in the query structure but I do not know what.
Please help!!!!
SELECT DISTINCTROW Max(UpdatesQry.Date) AS MaxOfDate,
First(UpdatesQry.Update) AS FirstOfUpdate, UpdatesQry.Final, [All Open Issues
Query].ID, [All Open Issues Query].Priority, [All Open Issues Query].[Date
Entered], [All Open Issues Query].Area, [All Open Issues Query].Department,
[All Open Issues Query].Issue, [All Open Issues Query].Resolution, [All Open
Issues Query].[Date Closed], UpdatesQry.IssueID
FROM [All Open Issues Query] INNER JOIN UpdatesQry ON [All Open Issues
Query].ID = UpdatesQry.IssueID
GROUP BY UpdatesQry.Final, [All Open Issues Query].ID, [All Open Issues
Query].Priority, [All Open Issues Query].[Date Entered], [All Open Issues
Query].Area, [All Open Issues Query].Department, [All Open Issues
Query].Issue, [All Open Issues Query].Resolution, [All Open Issues
Query].[Date Closed], UpdatesQry.IssueID;