STATISTIC |
DESCRIPTION |
SQL QUERY |
AVERAGE |
Take the average of the data points |
SELECT AVG(Value) FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 |
AVERAGEZERO |
Take the average of the data points, return zero (0) if result is BLANK. |
SELECT AVG(Value) FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 |
TOTAL |
Take the sum total of all values |
SELECT SUM(Value) FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 |
TOTALZERO |
Take the sum total of all values, return zero (0) if result is BLANK. |
SELECT SUM(Value) FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 |
MINIMUM |
Get the minimum value |
SELECT MIN(Value) FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 |
MAXIMUM |
Get the maximum value |
SELECT MAX(Value) FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 |
FIRST |
Get the first value |
SELECT TOP 1 Value, Timestamp FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 ORDER BY Timestamp |
LAST |
Get the last value |
SELECT TOP 1 Value, Timestamp FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 ORDER BY Timestamp DESC |
DIFF |
Calculate the difference between the first and last values. If the first value is larger than the second then it will perform the following calculation: (10 ^ (Ceil(LOG(first_value) / LOG(10)))) - first_value + last_value
Ceil will cause the value to round up |
- 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 FROM ihRawData WHERE Tagname='TANK_LEVEL' AND SamplingMode='RawByTime' AND Timestamp>='03/01/2009 00:00:00' AND Timestamp<'03/02/2009 00:00:00'
- Loop throught the records returned and sum the downward trends greater than the Deadband
|
MA10M |
Return a 10 minute moving average. 10 minutes is subtrated from the start time, and the end time is left as is. |
SELECT AVG(Value) FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='2/28/2009 23:50:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1450 |
MA4H |
Return a 4 hour moving average. 4 hours are subtracted from the start time, and the end time is left as is. |
SELECT AVG(Value) FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='2/28/2009 20:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1680 |
MA7D |
Return a 7 day moving average. 7 days are subtracted from the start time, and the end time is left as is. |
SELECT AVG(Value) FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='2/22/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=10080 |
RAINGAUGE |
Measures the volume of a rain gauge instrument. |
- SELECT Value FROM ihRawData WHERE Tagname='RAINGAUGE' AND SamplingMode='RawByTime' AND Timestamp>='03/01/2009 00:00:00' AND Timestamp<'03/02/2009 00:00:00'
- Loop throught the records returned and sum the downward trends greater than the Deadband
|
TIMEGT(x) |
Counts the number of values greater than the given number (x). If left unspecified it will use zero (0). |
SELECT COUNT(Value) FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 AND Value > x |
TIMELT(x) |
Counts the number of values less than the given number (x). If left unspecified it will use zero (0). |
SELECT COUNT(Value) FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 AND Value < x |
TIMEEQ(x) |
Counts the number of values equal to the given number (x). If left unspecified it will use zero (0). |
SELECT COUNT(Value) FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 AND Value = x |
CYCLE(x) |
Counts the number of times a value cycles to a particular number (x). |
1. Get LAST value from previous time period
2. Increment a running total when Value = x |
COUNT |
Counts the number of data points. |
SELECT COUNT(Value) FROM ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 |
MINTIME |
Returns the time of the minimum value as a text value, sets numeric value to 1 (one). |
SELECT Timestamp, MIN(Value) AS smin from ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 GROUP BY Timestamp ORDER BY smin, Timestamp |
MAXTIME |
Returns the time of the maximum value as a text value, sets numeric value to 1 (one). |
SELECT Timestamp, MAX(Value) AS smax from ihRawData WHERE SamplingMode='Lab' AND Tagname='EF_FLOW' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp <'3/2/2009 00:00:00' AND NumberofSamples=1440 GROUP BY Timestamp ORDER BY smax, Timestamp |
MOST |
Returns the most often seen value. |
SELECT Value, Count(*) FROM ihRawData GROUP BY Value WHERE Tagname='WEATHER' AND Samplingmode='interpolated' AND Timestamp>='3/1/2009 00:00:00' AND Timestamp<'3/2/2009 00:00:00' ORDER BY Count DESC |
MOST.COUNT |
Same as MOST but uses a custom query. |
Select Count(*) as Count, Value from ihRawData WHERE SamplingMode = Lab AND Tagname = 'WEATHER' AND TimeStamp > '05/18/2024 23:59:59' AND TimeStamp < '05/20/2024 00:00:00' AND criteriastring='#ONLYGOOD' GROUP BY value Order by Count Desc |