When I run the query in MySQL, I get the right result.
When I send the SQL statement from Machine SCADA Expert, the result is not right. It is like the lase WHERE clause is ignored.
This is the Query:
SELECT SUM(Minute_In_State) From (SELECT Time_Stamp, State, TIMESTAMPDIFF(SECOND, LAG(Time_Stamp) OVER(ORDER BY Time_Stamp), Time_Stamp) AS Minute_In_State FROM db.xyz_1_state ORDER BY Time_Stamp) AS T Where State = 1;
Any suggestion why the result is different, when sent from Machine SCADA Expert?