B
Barattolo_67
In database, I have three tables. THe first one has the audit findings, the
second one has the responses from the clients, and the third one has the
follow-up work on th implementation of the recommendation. In the last table
there may be multiple records tied up to that same finding and to that same
client response. I want to generate a query which will show the audit
finding, the management response, an only the LAST audit follow-up entry. I
have designed the below query, but it does not work and I do not get the last
record in the table "follow-up entries for findings".
INSERT INTO [Audit Follow-up Report] ( [No], [Thrust Area], [Title of
Issue], [Risk Severity Code], Recommendation, [Responsible Department],
[Management Action Plan], [Target Completion Date], [Revised Target Date],
[Actual Completion Date], [Follow-up Status], [Change History], [Management
Status Description], [Auditor's Comments] )
SELECT [tbl Comments].[Order of appearance], [tbl Comments].[Cycle Name],
[tbl Comments].[Comment Title], [tbl Comments].[Risk Severity Code], [tbl
Comments].Recommendation, [tbl Management Responses].[Responsible
Department], [tbl Management Responses].[Management Action Plan], [tbl
Management Responses].[Target Completion Date], [tbl Management
Responses].RevisedTargetDate, [tbl Management Responses].[Actual Completion
Date], [tbl Follow-up status codes].[Follow-up status code], [tbl Management
Responses].[Completion Date Change History and Other Comments], Last([tbl
Follow-up Entries for Findings].[Management's Status Description]) AS
[LastOfManagement's Status Description], Last([tbl Follow-up Entries for
Findings].[Auditor Comments]) AS [LastOfAuditor Comments]
FROM ([tbl Comments] LEFT JOIN ([tbl Follow-up status codes] RIGHT JOIN [tbl
Management Responses] ON [tbl Follow-up status codes].[Follow-up status
order] = [tbl Management Responses].[Follow-up status code]) ON [tbl
Comments].[Comment Table counter] = [tbl Management Responses].[Comment Table
counter]) LEFT JOIN [tbl Follow-up Entries for Findings] ON [tbl Management
Responses].[ID for tbl Management Responses] = [tbl Follow-up Entries for
Findings].[ID in tbl Management Responses]
GROUP BY [tbl Comments].[Order of appearance], [tbl Comments].[Cycle Name],
[tbl Comments].[Comment Title], [tbl Comments].[Risk Severity Code], [tbl
Comments].Recommendation, [tbl Management Responses].[Responsible
Department], [tbl Management Responses].[Management Action Plan], [tbl
Management Responses].[Target Completion Date], [tbl Management
Responses].RevisedTargetDate, [tbl Management Responses].[Actual Completion
Date], [tbl Follow-up status codes].[Follow-up status code], [tbl Management
Responses].[Completion Date Change History and Other Comments], [tbl
Comments].[Audit Report #]
HAVING ((([tbl Comments].[Audit Report #])="fa-lbr-04-03"))
ORDER BY [tbl Comments].[Order of appearance];
Any clue?
second one has the responses from the clients, and the third one has the
follow-up work on th implementation of the recommendation. In the last table
there may be multiple records tied up to that same finding and to that same
client response. I want to generate a query which will show the audit
finding, the management response, an only the LAST audit follow-up entry. I
have designed the below query, but it does not work and I do not get the last
record in the table "follow-up entries for findings".
INSERT INTO [Audit Follow-up Report] ( [No], [Thrust Area], [Title of
Issue], [Risk Severity Code], Recommendation, [Responsible Department],
[Management Action Plan], [Target Completion Date], [Revised Target Date],
[Actual Completion Date], [Follow-up Status], [Change History], [Management
Status Description], [Auditor's Comments] )
SELECT [tbl Comments].[Order of appearance], [tbl Comments].[Cycle Name],
[tbl Comments].[Comment Title], [tbl Comments].[Risk Severity Code], [tbl
Comments].Recommendation, [tbl Management Responses].[Responsible
Department], [tbl Management Responses].[Management Action Plan], [tbl
Management Responses].[Target Completion Date], [tbl Management
Responses].RevisedTargetDate, [tbl Management Responses].[Actual Completion
Date], [tbl Follow-up status codes].[Follow-up status code], [tbl Management
Responses].[Completion Date Change History and Other Comments], Last([tbl
Follow-up Entries for Findings].[Management's Status Description]) AS
[LastOfManagement's Status Description], Last([tbl Follow-up Entries for
Findings].[Auditor Comments]) AS [LastOfAuditor Comments]
FROM ([tbl Comments] LEFT JOIN ([tbl Follow-up status codes] RIGHT JOIN [tbl
Management Responses] ON [tbl Follow-up status codes].[Follow-up status
order] = [tbl Management Responses].[Follow-up status code]) ON [tbl
Comments].[Comment Table counter] = [tbl Management Responses].[Comment Table
counter]) LEFT JOIN [tbl Follow-up Entries for Findings] ON [tbl Management
Responses].[ID for tbl Management Responses] = [tbl Follow-up Entries for
Findings].[ID in tbl Management Responses]
GROUP BY [tbl Comments].[Order of appearance], [tbl Comments].[Cycle Name],
[tbl Comments].[Comment Title], [tbl Comments].[Risk Severity Code], [tbl
Comments].Recommendation, [tbl Management Responses].[Responsible
Department], [tbl Management Responses].[Management Action Plan], [tbl
Management Responses].[Target Completion Date], [tbl Management
Responses].RevisedTargetDate, [tbl Management Responses].[Actual Completion
Date], [tbl Follow-up status codes].[Follow-up status code], [tbl Management
Responses].[Completion Date Change History and Other Comments], [tbl
Comments].[Audit Report #]
HAVING ((([tbl Comments].[Audit Report #])="fa-lbr-04-03"))
ORDER BY [tbl Comments].[Order of appearance];
Any clue?