Best fit retrieval - query example
- Last UpdatedFeb 06, 2025
- 1 minute read
To use the best fit retrieval mode, set the following parameter in your query.
wwRetrievalMode = 'BestFit'
For example, an analog tag is retrieved over a five-minute period using the best-fit retrieval mode. The wwResolution parameter is set to 60000, thus specifying five 1-minute cycles. Within each cycle, the retrieval sub-system returns the first, minimum, maximum, and last data points. There are no exception (NULL) points in the time period. Notice how the points at the query start time and at the query end time are interpolated, while all other points are actual delta points.
SELECT DateTime, TagName, CONVERT(DECIMAL(10, 1), Value) AS Value, wwInterpolationType AS IT FROM History
WHERE TagName = 'ReactTemp'
AND DateTime >= '2005-04-11 12:15:00'
AND DateTime <= '2005-04-11 12:20:00'
AND wwRetrievalMode = 'BestFit'
AND wwResolution = 60000
The results are:
|
DateTime |
TagName |
Value |
IT |
|
|---|---|---|---|---|
|
(initial, first, min) |
2005-04-11 12:15:00.000 |
ReactTemp |
40.7 |
LINEAR |
|
(max in interval 1) |
2005-04-11 12:15:38.793 |
ReactTemp |
196.0 |
STAIRSTEP |
|
(last in interval 1) |
2005-04-11 12:15:58.810 |
ReactTemp |
159.2 |
STAIRSTEP |
|
(first, max in interval 2) |
2005-04-11 12:16:00.013 |
ReactTemp |
156.9 |
STAIRSTEP |
|
(last, min in interval 2) |
2005-04-11 12:16:58.857 |
ReactTemp |
16.3 |
STAIRSTEP |
|
(first, min in interval 3) |
2005-04-11 12:17:00.060 |
ReactTemp |
14.0 |
STAIRSTEP |
|
(last, max in interval 3) |
2005-04-11 12:17:58.793 |
ReactTemp |
151.0 |
STAIRSTEP |
|
(first in interval 4) |
2005-04-11 12:18:00.107 |
ReactTemp |
156.0 |
STAIRSTEP |
|
(max in interval 4) |
2005-04-11 12:18:10.057 |
ReactTemp |
196.0 |
STAIRSTEP |
|
(last, min in interval 4) |
2005-04-11 12:18:58.837 |
ReactTemp |
106.3 |
STAIRSTEP |
|
(first, max in interval 5) |
2005-04-11 12:19:00.040 |
ReactTemp |
104.0 |
STAIRSTEP |
|
(min in interval 5) |
2005-04-11 12:19:31.320 |
ReactTemp |
14.0 |
STAIRSTEP |
|
(last in interval 5) |
2005-04-11 12:19:58.773 |
ReactTemp |
26.0 |
STAIRSTEP |
|
(end bounding value) |
2005-04-11 12:20:00.000 |
ReactTemp |
30.7 |
LINEAR |