IH:ihRawData Examples

本文提供了多个关于ihRawData表的SQL查询示例,包括获取特定条件下的样本、统计不良样本数量、按时间排序的事件序列等。这些示例有助于理解和掌握如何高效地从大型数据集中检索所需信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ihRawData Examples
The ihRawData table can generate a large number of rows if not used with caution. You can easily generate queries which take a very long time to complete and put stress on the archiver and generate network traffic.

Tasks that you might want to perform on the ihRawData table are outlined in the following examples.

Example 1: Retrieving All Samples Where a Value Was Outside the Query Supplied Values
SELECT * FROM ihRawData WHERE value<140000 OR value>150000

Example 2: Retrieving All Bad Samples (Raw Data)
SELECT * FROM ihRawData WHERE quality NOT LIKE good*

AND samplingmode=RawbyTime

Example 3: Counting the Number of Bad Samples (Raw Data)
SELECT COUNT() FROM ihRawData WHERE quality NOT LIKE good

AND samplingmode=RawbyTime

Example 4: Retrieving All Bad Samples Over the Last Day (Interpolated Data)
SELECT timestamp, tagname, value, quality FROM ihRawData

WHERE samplingmode=rawbytime

AND Quality NOT LIKE good*

AND timestamp>=Now-24H

Example 5: Using an Explicit Time Zone
SELECT * FROM ihRawData WHERE timezone=300

Example 6: Performing a Simple Sequence of Events
SELECT timestamp, tagname, value, quality FROM ihrawdata

WHERE samplingmode=rawbytime ORDER BY timestamp

Example 7: Reporting the Busiest Tags
SELECT tagname, value FROM ihRawData

WHERE samplingmode=calculated

AND calculationmode=count

AND numberofsamples=1

AND timestamp>=‘07/30/2002 10:00:00’

AND timestamp<=‘07/30/2002 11:00:00’ order by value descending

Example 8: Retrieving All Bad Samples Over the Last Day
SELECT timestamp, tagname, value, quality FROM ihRawData

WHERE samplingmode=rawbytime

AND Quality NOT LIKE good*

AND timestamp>=Now-24H

Example 9: Retrieving All Bad Samples, Ignoring End of Collection Markers
SELECT timestamp, tagname, value, quality FROM ihRawData

WHERE samplingmode=rawbytime

AND Quality NOT LIKE good*

AND quality NOT LIKE ‘bad offline’

AND timestamp>=Now-24H

Example 10: Counting the Number of Bad Samples, Ignoring End of Collection Markers
SELECT COUNT(*) FROM ihRawData WHERE samplingmode=rawbytime

AND Quality NOT LIKE good* and quality NOT LIKE ‘bad offline’

AND timestamp>=Now-24H

Example 11: Obtaining All Raw Samples from Yesterday with a Comment
SELECT ihRawData.Tagname, ihRawData.TimeStamp, ihRawData.Value

FROM ihRawData

INNER JOIN ihComments ON ihComments.Tagname = ihRawData.Tagname

AND ihComments.Timestamp = ihRawData.Timestamp

AND ihComments.Comment = “The comment”

WHERE samplingmode=rawbytime

AND ihComments.Timestamp > Yesterday

AND ihComments.Timestamp < Today

Example 12: Determining the Number of Milliseconds Per Interval with Good Data
SELECT timestamp, tagname, value as TimeGood, quality, intervalmilliseconds FROM ihRawData

WHERE tagname=Denali.Simulation00001

AND samplingmode=calculated

AND calculationmode=timegood

AND intervalmilliseconds=10s

AND timestamp>=‘1/20/2003 13:18:00’

AND timestamp<=‘1/20/2003 13:20:00’

Example 13: Retrieving Raw Minimum and Maximum Values per Interval
In this example, you use the data retrieved from the query (with the Trend sampling mode) for plotting points.

SELECT timestamp, tagname, value, quality

FROM ihRawData

WHERE tagname=dFloatTag5

AND samplingmode=trend

AND intervalmilliseconds=24h

AND timestamp>=‘1/01/2003 07:00:00’

AND timestamp<=‘1/10/2003 12:00:00’

Example 14: Retrieving Data with Native Values if the Tag is associated with an Enumerated Set
If enumsetrawvalue is set False, the data is retrieved with string values by default. If enumsetrawvalue is set to True, the raw values are retrieved. Once set, these values are retrieved by default for the current session and will only change when you open a new session.

SELECT * from ihrawdata

WHERE samplingmode=‘rawbytime’ and tagname=mytag

and enumsetrawvalue=TRUE

SELECT timestamp,value,quality from ihrawdata WHERE tagname = MyTag

and samplingmode=Interpolated and numberofsamples=6 and criteriastring=‘enumnativevalue’

SET enumsetrawvalue=’TRUE’

SELECT * from ihrawdata

WHERE samplingmode=‘rawbytime’ and tagname=mytag

Example 15: Retrieving Average Values for Enumerated Set
SET enumsetrawvalue=’FALSE’

SELECT * from ihrawdata

WHERE tagname like Call and samplingmode=calculated

and calculationmode=average

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值