SQL: Error binding needs "double"

I am having a tag quality Error_DatabaseQuery.

It is giving value however it is in red because of quality.

Exception: Conversion error: query returned null, binding needs “double”
on query binding for “Main Window.Root Container.Numeric Label 6.value”

Ignition v8.0.15 (b2020072213)
Java: Azul Systems, Inc. 11.0.6

This is my SQL:
SELECT
avg((M1Kw+
M2Kw+
M3Kw+
M4Kw+
M5Kw+M6kw))*24 as “kWh”
FROM
plant_power
Where
Date(t_stamp - interval 5 hour) = Date(date_sub(current_timestamp, interval 1 day))
How do i get this not to be red. I tried resetting the SQL and nothing. Please help.

Try testing the query in the Database Query Browser and see what error messages it generates. I suspect that the Interval function may not be supported by Ignition as it is MS SQL specific (I think). You might need to use something more generic like DATEADD().

Tip: can you edit your post, select the SQL code and hit the </> code formatting button?

1 Like