Hi, any help would be greatly appreciated. I currently have two tables which I am joining. Both of these tables will be joined based on a date/time field.
Table 1 = PreTemp(Date_Time, Temperature, Pressure)
Table 2 = Spd (Date_TimeSpd, Speed).
The purpose of the join is to select records which match and records which are 5 seconds previous to PreTemp's record date_time e.g. 18:34:17 is in PreTemp so 18:34:15 will be selected.
My current sql code is:
<code>
SELECT *
FROM PreTemp AS p1
INNER JOIN (SELECT * FROM Spd ORDER BY Spd.Date_TimeSpd DESC) AS s1
ON (p1.Date_Time=s1.Date_TimeSpd) Or (p1.Date_Time>=s1.Date_TimeSpd
And s1.Date_TimeSpd>=(p1.Date_Time-(5/86400)));
</code>
This does the job to some extent but it selects more than one record in the last 5 seconds, what I need is to select the most up-to-date record in the last 5 seconds from the Spd table based on the date_time field in the PreTemp table.
Please can you help me, thanks.