Example 3: querying the widehistory table
- Last UpdatedMar 19, 2025
- 1 minute read
If you execute a query on the WideHistory table for analog tags, wwResolution shows the time between the first value change for ANY of the tags.
SELECT * FROM OpenQuery(INSQL,'
SELECT DateTime, SysTimeSec, SysTimeMin, wwResolution
FROM WideHistory
WHERE DateTime >= "20120119 12:44:00.000"
AND DateTime <= "20120119 12:45:00.000"
AND wwRetrievalMode = "Delta"
')
The results are:
|
DateTime |
SysTimeSec |
SysTimeMin |
wwResolution |
|---|---|---|---|
|
2012-01-19 12:44:00.0000000 |
0 |
44 |
1000 |
|
2012-01-19 12:44:01.0000000 |
1 |
44 |
1000 |
|
2012-01-19 12:44:02.0000000 |
2 |
44 |
1000 |
|
2012-01-19 12:44:03.0000000 |
3 |
44 |
1000 |
|
2012-01-19 12:44:04.0000000 |
4 |
44 |
1000 |
|
2012-01-19 12:44:05.0000000 |
5 |
44 |
1000 |
|
... |
The wwResolution column shows 1000 milliseconds because the smallest time change is for the SysTimeSec tag, which is changing every second.
If you run the same query using the SysTimeHour tag instead of the SysTimeSec tag, the results are:
|
DateTime |
SysTimeHour |
SysTimeMin |
wwResolution |
|---|---|---|---|
|
2012-01-19 12:44:00.0000000 |
12 |
44 |
60000 |
|
2012-01-19 12:45:00.0000000 |
12 |
45 |
0 |
The wwResolution column shows 60000 milliseconds because the smallest time change is for the SysTimeMin tag, which is changing every minute (every 60 seconds). Because the query ended at the time of the last value, a 0 is shown for wwResolution for the ending value.