Selasa, 02 Juni 2015

RE: [MS_AccessPros] Query speed

 

Ken,
What fields have indexes?
 
Duane
 

To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Tue, 2 Jun 2015 08:51:19 -0700
Subject: [MS_AccessPros] Query speed




I have several queries that are causing the main query to run slow. 


SELECT M.[Meter Name], R1.ReadingDate, R1.MeterReading, R2.ReadingDate AS PrevReadingDate, R2.MeterReading AS PrevMeterReading, [R1].[MeterReading]-([PrevMeterReading]+[R2].[Refill]) AS Use, Abs([Use]) AS TTLUsed, R2.Refill, R2.[Floride_Added_#]
FROM [Meter Information] AS M INNER JOIN ([Water Meter Readings] AS R1 LEFT JOIN [Water Meter Readings] AS R2 ON R1.frg_MeterID = R2.frg_MeterID) ON M.MeterID = R1.frg_MeterID
WHERE (((M.[Meter Name])="Fluoride") AND ((R2.ReadingDate)=(SELECT Max(R3.ReadingDate)
      FROM [Water Meter Readings] AS R3  
      WHERE (R3.frg_MeterID = R1.frg_MeterID)  
        AND (R3.ReadingDate < R1.ReadingDate)    
    ))) OR (((R2.frg_MeterID) Is Null))
ORDER BY M.[Meter Name], R1.ReadingDate;


Any help is appreciated.
Ken


__._,_.___

Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

.

__,_._,___

Tidak ada komentar:

Posting Komentar