Different return values from ignition DB

I ran a query to retrieve data from the same table in MSSQL and in ignition "Named queries" but the results were not the same. Therefore, I did a manual calculation using Excel and it was matched with MSSQL output.

I wanted to get monthly averaged data from the table<
Same as I ran the query per monthly(one by one) on Ignition DB and those values were matched with MSSQL output.
What could be the reason?


MSSQL Output

Ignition DB Output

It looks like we are dealing with three fields on which you want to perform some aggregate functions and miscellaneous functions. Ignition is not the best at handling complex SQL, so I would create a stored procedure that returns the dataset you are looking for. You might be able to create a function (?) to handle the formatting and conversion of the field t_stamp as well.

Your named query then would call the SP, passing any parameters as needed.

e.g. EXEC usp_MyAveragePower :param1, :param2

1 Like

I dont have any parameters to send. I need to get the average values of some data which is needed for another mathematical calculation.

I found a way to create a SP in the MSSQL and called it through Named Queries. It worked.
Thank you very much