How to make sql query the average value of a tag in the last hour

A have historical tag with address [default]TESTSTARTSTOP/Hours/Active power .How to make sql query the average value of this tag in the last hour?


How would you like to query your tag (with a property binding ? in a chart ? in a table ?)

One thing for sure is that you can do this using script.
I would suggest you to check out this part of the user manual :

Why not using a transaction group to store your tag ?
This way you can have control on the table name, the column where your tag will be stored and it will be easier to use complex SQL queries .


I think the queryTagCalculations function would be more appropriate:

1 Like

Hi @nminchin, until this point i was trying to query manually from the Historian DB. This is the way, thank you very much.