Hi
I am struggling to try an opimise two queries and am not sure that there is any obvious way, can anybody help?
Many thanks
Simon
SELECT
SUM(B.Length) AS [Length_Poor]
FROM
tbl_Residual_Life_Sections_Run AS A
INNER JOIN
tbl_Residual_Life_Readings_Run AS B
ON
A.ID = B.Section_ID
WHERE
A.Section NOT IN (SELECT Section FROM tbl_Schemes_Run WHERE Year = 2004)
AND NOT B.Long_Life AND B.[2004] <= 0 AND A.Start_Year <= 2004
AND A.End_Year > 2004
Set recData = pdtbUser.OpenRecordset(strSQL, dbOpenSnapshot)
lngResidualLifeLength = IIf(IsNull(recData.Fields("Length_Poor")), 0, recData.Fields("Length_Poor"))
SELECT
SUM(Length) AS [Length_Poor]
FROM
tbl_Rutting_Sections_Run AS A
INNER JOIN
tbl_Rutting_Readings_Run AS B
ON
A.ID = B.Section_ID
WHERE
A.Section NOT IN (SELECT Section FROM tbl_Schemes_Run WHERE Year = 2004)
AND
B.[2004] <= B.Investigatory_Level
AND
A.Start_Year <= 2004
AND
A.End_Year > 2004
Set recData = pdtbUser.OpenRecordset(strSQL, dbOpenSnapshot)
lngRuttingLength = IIf(IsNull(recData.Fields("Length_Poor")), 0, recData.Fields("Length_Poor"))
I am struggling to try an opimise two queries and am not sure that there is any obvious way, can anybody help?
Many thanks
Simon
SELECT
SUM(B.Length) AS [Length_Poor]
FROM
tbl_Residual_Life_Sections_Run AS A
INNER JOIN
tbl_Residual_Life_Readings_Run AS B
ON
A.ID = B.Section_ID
WHERE
A.Section NOT IN (SELECT Section FROM tbl_Schemes_Run WHERE Year = 2004)
AND NOT B.Long_Life AND B.[2004] <= 0 AND A.Start_Year <= 2004
AND A.End_Year > 2004
Set recData = pdtbUser.OpenRecordset(strSQL, dbOpenSnapshot)
lngResidualLifeLength = IIf(IsNull(recData.Fields("Length_Poor")), 0, recData.Fields("Length_Poor"))
SELECT
SUM(Length) AS [Length_Poor]
FROM
tbl_Rutting_Sections_Run AS A
INNER JOIN
tbl_Rutting_Readings_Run AS B
ON
A.ID = B.Section_ID
WHERE
A.Section NOT IN (SELECT Section FROM tbl_Schemes_Run WHERE Year = 2004)
AND
B.[2004] <= B.Investigatory_Level
AND
A.Start_Year <= 2004
AND
A.End_Year > 2004
Set recData = pdtbUser.OpenRecordset(strSQL, dbOpenSnapshot)
lngRuttingLength = IIf(IsNull(recData.Fields("Length_Poor")), 0, recData.Fields("Length_Poor"))