- Local time
- Today, 09:08
- Joined
- Sep 28, 2010
- Messages
- 83
I'm using an expression to concatenate results within a query (three text fields), but having, relatively recently, learnt of the "unsuitability" of the LAST function, I'm aware that I cannot trust the output of this particular part of the query..
The Expression is currently this :
What I would like to do is add in a WHERE clause to tie down the 3 "Fault Desc" fields to those that match the Max Job No for the docket in question..
Note :
Docket = Lifespan call reference
Job No = Unique Job Identifier
The full "SQL" code for the query at present is below
Anyone got any thoughts?
TIA..
The Expression is currently this :
Code:
Fault_Description: Last([dbo_ReportData].[Fault Desc 1]) & " " & Last([dbo_ReportData].[fault desc 2]) & " " & Last([dbo_ReportData].[fault desc 3])
What I would like to do is add in a WHERE clause to tie down the 3 "Fault Desc" fields to those that match the Max Job No for the docket in question..
Note :
Docket = Lifespan call reference
Job No = Unique Job Identifier
The full "SQL" code for the query at present is below
Code:
SELECT DISTINCT dbo_ReportData.DOCKET, dbo_ReportData.site_search, Priority_Grouping.Category, Priority_Grouping.Priority, Prod_ShortCode.ShortCode, Prod_ShortCode.HighLevelGroup, dbo_ReportData.Description, Count(dbo_ReportData.[Job No]) AS [CountOfJob No], Sum(dbo_ReportData.[Response Time]) AS [SumOfResponse Time], Sum(dbo_ReportData.[Fix Time]) AS [SumOfFix Time], Min(dbo_ReportData.[Received Date]) AS [MinOfReceived Date], Max(dbo_ReportData.[Completion Date]) AS [MaxOfCompletion Date], Last([dbo_ReportData].[Fault Desc 1]) & " " & Last([dbo_ReportData].[fault desc 2]) & " " & Last([dbo_ReportData].[fault desc 3]) AS Fault_Description, Last([dbo_ReportData].[Work Done 1]) & " " & Last([dbo_ReportData].[Work Done 2]) AS Work_Done
FROM Prod_ShortCode INNER JOIN (Priority_Grouping INNER JOIN dbo_ReportData ON Priority_Grouping.Priority = dbo_ReportData.Priority) ON Prod_ShortCode.Description = dbo_ReportData.Description
WHERE (((dbo_ReportData.[Log Num])=1 Or (dbo_ReportData.[Log Num])=2 Or (dbo_ReportData.[Log Num])=3 Or (dbo_ReportData.[Log Num])=5 Or (dbo_ReportData.[Log Num])=6 Or (dbo_ReportData.[Log Num])=12 Or (dbo_ReportData.[Log Num])=24 Or (dbo_ReportData.[Log Num])=36) AND ((dbo_ReportData.[Completion Date]) Between [Enter Start Date] And [Enter End Date]) AND ((dbo_ReportData.[Site Group]) Like [Enter Site Group]))
GROUP BY dbo_ReportData.DOCKET, dbo_ReportData.site_search, Priority_Grouping.Category, Priority_Grouping.Priority, Prod_ShortCode.ShortCode, Prod_ShortCode.HighLevelGroup, dbo_ReportData.Description
ORDER BY Count(dbo_ReportData.[Job No]) DESC;
Anyone got any thoughts?
TIA..