Das was Du da machst, lässt mir die Haare zu Berge steigen
Du kannst den ganzen Spass mit einem einzigen
SQL-Statement erledigen (dafür sind ja "richtige"
DB's da), ohne das alles in Delphi machen zu müssen.
Versuch es mal mit:
SQL-Code:
INSERT INTO Datenbank_D
SELECT SUM(C.[Fin2ManTempFB] )/COALESCE(COUNT(C.*),1)
, SUM(C.[Heater T1 Gas Valve])/COALESCE(COUNT(C.*),1)
, SUM(C.[Heater T3 Gas Valve])/COALESCE(COUNT(C.*),1)
, SUM(C.[PLCCW1TarWG] )/COALESCE(COUNT(C.*),1)
, SUM(C.[PLCCW2TarWG] )/COALESCE(COUNT(C.*),1)
, SUM(C.[SupBlwr2\Speed] )/COALESCE(COUNT(C.*),1)
, SUM(C.[SupBlwr3\Speed] )/COALESCE(COUNT(C.*),1)
FROM Datenbank_A A
INNER JOIN Datenbank_B B
ON B.Nummer = A.Nummer
INNER JOIN Datenbank_C C
ON C.Date_Time BETWEEN min(B.Date_Time) AND max(B.Date_Time)
GROUP BY A.NUMMER
Gruß