Jumat, 05 Juni 2015

Re: [MS_AccessPros] Re: Query speed

 

From query I posted earlier


Old Code: (SELECT Max(R3.ReadingDate)
      FROM [Water Meter Readings] AS R3  
      WHERE (R3.frg_MeterID = R1.frg_MeterID)  
        AND (R3.ReadingDate < R1.ReadingDate)    
    )

New Code: [R1].[ReadingDate]-1

M is alias for table [Meter Information] R1 is alias for table [Water Meter Readings] R2 is alias for Water Meter Readings

M table [Meter ID] Joins frg_MeterID one to one and R1frg_MeterID Joins R2 frg_MeterID one to many

The above code was to retrieve the previous record regardless of Date. The current code requires all days to be entered. The database runs quickly with the new code.  Is there a better way to retrieve the last record instead of subtracting days. I look at selecting an ID field but am afraid of deleted records. I hope this makes sense.
Ken


__._,_.___

Posted by: statmanbp@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (7)

.

__,_._,___

Tidak ada komentar:

Posting Komentar