Integral retrieval - wwExpression query example
- Last UpdatedFeb 06, 2025
- 1 minute read
In this example, the integral of a tag named Speed (measured in m/s), is computed over two 1-minute long intervals (wwResolution = 60000 milliseconds) to measure the distance traveled in meters over the interval.
SELECT StartDateTime, DateTime, TagName, Value, Quality, QualityDetail as QD, wwUnit
FROM History
WHERE TagName = 'Speed'
AND DateTime >= '2020-12-03 10:00'
AND DateTime < '2020-12-03 10:02'
AND wwRetrievalMode = 'Integral'
AND wwResolution = 60000
The results are:
|
StartDateTime |
DateTime |
TagName |
Value |
Quality |
QD |
wwUnit |
|---|---|---|---|---|---|---|
|
2020-12-03 09:59:00.000 |
2020-12-03 10:00:00.000 |
Speed |
-2906.88948 |
0 |
192 |
m |
|
2020-12-03 10:00:00.000 |
2020-12-03 10:01:00.000 |
Speed |
877.57619 |
0 |
192 |
m |
To display the results using a different unit of measure, you can use the wwExpression query parameter with the following syntax:
wwExpression = 'UOM(TagName, target unit)'
For example, the integral of the Speed tag is computed again over two 1-minute long intervals, but this time the value is converted to the distance in centimeters.
SELECT StartDateTime, DateTime, TagName, Value, Quality, QualityDetail as QD, wwUnit
FROM History
WHERE TagName = 'Speed'
AND DateTime >= '2020-12-03 10:00'
AND DateTime < '2020-12-03 10:02'
AND wwRetrievalMode = 'Integral'
AND wwResolution = 60000
AND wwExpression = 'UOM([Speed],cm)'
The results are:
|
StartDateTime |
DateTime |
TagName |
Value |
Quality |
QD |
wwUnit |
|---|---|---|---|---|---|---|
|
2020-12-03 09:59:00.000 |
2020-12-03 10:00:00.000 |
Speed |
-290688.948 |
192 |
192 |
cm |
|
2020-12-03 10:00:00.000 |
2020-12-03 10:01:00.000 |
Speed |
87757.619 |
192 |
192 |
cm |
Note: Engineering unit conversion requires the advanced feature license. If your Historian does not have the advanced feature license activated, the results are returned in the original units.