History version - query example
- Last UpdatedFeb 07, 2025
- 1 minute read
This example illustrates using history version. First, consider this query:
SELECT TagName, DateTime, Value, wwVersion
FROM History
WHERE TagName IN ('SysTimeHour', 'SysTimeMin')
AND DateTime >= '2001-12-20 0:00'
AND DateTime <= '2001-12-20 0:05'
AND wwRetrievalMode = 'Delta'
AND wwVersion = 'Original'
The results are:
|
TagName |
DateTime |
Value |
wwVersion |
|
SysTimeMin |
2001-12-20 00:00:00.000 |
0 |
ORIGINAL |
|
SysTimeHour |
2001-12-20 00:00:00.000 |
0 |
ORIGINAL |
|
SysTimeMin |
2001-12-20 00:01:00.000 |
1 |
ORIGINAL |
|
SysTimeMin |
2001-12-20 00:02:00.000 |
2 |
ORIGINAL |
|
SysTimeMin |
2001-12-20 00:03:00.000 |
3 |
ORIGINAL |
|
SysTimeMin |
2001-12-20 00:04:00.000 |
4 |
ORIGINAL |
|
SysTimeMin |
2001-12-20 00:05:00.000 |
5 |
ORIGINAL |
When retrieving the latest version, the wwVersion parameter always returns with a value of LATEST for all values, even though many of the values may actually be the original values that came from the I/O Server. To distinguish between an actual latest value and an original value, a special QualityDetail of 202 is returned for a good, latest point. Note, however, that replicated data may show a QualityDetail of 202 for points other than the latest point.
For example:
SELECT DateTime, Value, Quality, QualityDetail, OPCQuality, wwVersion
FROM History
WHERE TagName IN ('PV')
AND DateTime >= '2005-04-17 11:35:00'
AND DateTime <= '2005-04-17 11:36:00'
AND wwRetrievalMode = 'Delta'
AND wwVersion = 'Latest'
The results are:
|
DateTime |
Value |
Quality |
QualityDetail |
OPCQuality |
wwVersion |
|---|---|---|---|---|---|
|
2005-04-17 11:35:00.000 |
12.5 |
0 |
192 |
192 |
LATEST |
|
2005-04-17 11:35:15.000 |
17.3 |
0 |
192 |
192 |
LATEST |
|
2005-04-17 11:35:30.000 |
34.0 |
0 |
202 |
192 |
LATEST |
|
2005-04-17 11:35:45.000 |
43.1 |
0 |
192 |
192 |
LATEST |
|
2005-04-17 11:36:00.000 |
51.2 |
0 |
192 |
192 |
LATEST |