STATISTIC |
DESCRIPTION |
SQL QUERY (Getting data for hourly variable for the 1st hour of January 3rd, 2017. |
AVERAGE |
Take the average of the data points |
select Avg(Value) as Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1
With Range Filtering (Low range set to 10 and High Range set to 60):
select Avg(Value) as Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND Value >=10 AND Value <=60 AND IsGood(Quality) = 1 |
AVERAGEZERO |
Take the average of the data points, return zero (0) if result is BLANK. |
select Avg(Value) as Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 |
SUM |
Take the sum total of all values |
select Sum(Value) as Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 |
SUMZERO |
Take the sum total of all values, return zero (0) if result is BLANK. |
select Sum(Value) as Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 |
MINIMUM |
Get the minimum value |
select Min(Value) as Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 |
MAXIMUM |
Get the maximum value |
select Max(Value) as Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 |
FIRST |
Get the first value |
select Value, TimeStamp from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 ORDER BY Timestamp ASC |
LAST |
Get the last value |
select Value, TimeStamp from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 ORDER BY Timestamp DESC |
DIFF |
Typically used with totalizers to calculate the actual usage (runhours, flow, etc... from the meter). Calculate the difference between the first and last values. If the first value is larger than the second it determines that the meter "rolled over" at the next power of 10. |
- Get FIRST value
- Get LAST value
- RESULT = LAST - FIRST
- IF RESULT < 0 THEN (10 ^ (Ceil(LOG(first_value) / LOG(10)))) - first_value + last_value
|
RANGE |
Calculate the absolute value of the difference between the minimum and maximum values |
- Get MIN value
- Get MAX value
- Get ABS(MIN - MAX)
|
INVENTORY |
Return the total use based on a tank level signal. For example, the level is 10 feet at midnight and slowly goes down to 2 feet at 2:00 PM, then gets filled to 15 feet and slowly goes down to 8 feet at midnight. The inventory function would return ((10 - 2) + (15 - 8)) = 15. |
-
select Value, TimeStamp from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 ORDER BY Timestamp ASC
- Loop through the records returned and sum the downward trends greater than the Deadband
|
TIMEGT(x) |
Calculates the number of seconds the value was greater then the given number (x). If left unspecified it will use zero (0). |
- SELECT UTCToLocalTime(TimeStamp) as TimeStamp,Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 ORDER BY Timestamp ASC
- Loop through records and sum the times the value is greater than x. The value is considered greater that x from the record where it was greater than until a record is no longer greater than. Example TIMEGT(10):
00:00:00 8.2 00:00:10 10.2 00:00:20 10.3 00:00:30 9.8
It would calculate that is greater then for 20 seconds (ie from 00:00:10 until 00:00:30) |
TIMELT(x) |
Calculates the number of seconds the value was less then the given number (x). If left unspecified it will use zero (0). |
SELECT UTCToLocalTime(TimeStamp) as TimeStamp,Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 ORDER BY Timestamp ASC |
TIMEEQ(x) |
Calculates the number of seconds the value was equal to the given number (x). If left unspecified it will use zero (0). |
SELECT UTCToLocalTime(TimeStamp) as TimeStamp,Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 ORDER BY Timestamp ASC |
CYCLE(x) |
Counts the number of times a value cycles to a particular number (x). |
1. Get LAST value from previous time period
2. SELECT UTCToLocalTime(TimeStamp) as TimeStamp,Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 ORDER BY Timestamp ASC
3. Loop thru records and increment counter every time the value equals X and the previous value was not X. |
COUNT |
Counts the number of data points. |
select Count(Value) as Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 |
MINTIME |
Returns the time of the minimum value as a text value, sets numeric value to 1 (one). |
- SELECT UTCToLocalTime(TimeStamp) as TimeStamp,Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 ORDER BY Timestamp ASC
- Loop thru records and records the time of the first miniumum value.
|
MAXTIME |
Returns the time of the maximum value as a text value, sets numeric value to 1 (one). |
- SELECT UTCToLocalTime(TimeStamp) as TimeStamp,Value from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 ORDER BY Timestamp ASC
- Loop thru records and records the time of the first maximum value.
|
PERCENTBAD |
Returns the most often seen value. |
- SELECT UTCToLocalTime(TimeStamp) as TimeStamp,Value, Quality from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2017-01-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 ORDER BY Timestamp ASC
- Loop through records and sum the times the quality is greater than 0.
|
LASTHOLD |
Get the last value. Looks back one month. |
select Value, TimeStamp from RawData WHERE TAGNAME = 'Signals/Random' AND TimeStamp >= LocalTimeToUTC('2016-12-03 00:00:00') AND TimeStamp < LocalTimeToUTC('2017-01-03 01:00:00') AND IsGood(Quality) = 1 ORDER BY Timestamp DESC |