How does one query across monthly data tables?

I can’t find an explanation in the documentation.

If I write an SQL query I have to pass the table name. How do I ensure that I get records in preceding months (and future months when the time comes)?

Many thanks.

The system.tag.queryTagHistory() script function and Tag History Binding take care of this for you. If you must write your own SQL, you will have to construct UNION statements for the tables yourself. You would construct the table names programmatically and duplicate your filter criteria for each table involved.


you can also manually query it

I slightly delved into this a couple years ago.

You can find it here … 70&t=13656

Thanks, diat150. I think I figured out a good way yesterday - see … 94&t=16738.

The basic create a table to retrieve the required data from the historian. This solves all the problems of tagid, spanning multiple tables, data types, etc. Then write a script to examine / manipulate the returned dataset and feed that out to another table. The first table would be invisible in run mode. The Python code can be very simple.


Amazing that a software package like this cannot cross multiple tables without JOINS etc.

But it can with system.tag.queryTagHistory Its only if you want to write your own query that you are restricted to writing regular SQL queries with joins and such.

1 Like

what you mean