SQL query examples
- Last UpdatedMar 20, 2025
- 1 minute read
In addition to query examples that use the AVEVA Historian time domain extensions, other query examples are provided to demonstrate how to perform more complex queries or to further explain how retrieval works.
The examples provided are not exhaustive of all possible database queries, but they should give you an idea of the kinds of queries that you could write.
For general information on creating SQL queries, see your Microsoft SQL Server documentation.
Note: If you have configured SQL Server to be case-sensitive, be sure that you use the correct case when writing queries.
Related Links
- Querying the History table
- Querying the Live table
- Querying the WideHistory table
- Querying wide tables in delta retrieval mode
- Querying the AnalogSummaryHistory view
- Querying the StateSummaryHistory view
- Use SliceBy
- Querying metadata with the latest value
- Use an unconventional tagname in a wide table query
- Use an inner remote join
- Setting both a time and value deadband for retrieval
- Use wwResolution, wwCyclecount, and wwRetrievalmode in the same query
- Determining cycle boundaries
- Mixing tag types in the same query
- Use a criteria condition on a column of variant data
- Use DateTime functions
- Use the GROUP BY clause
- Use the COUNT() function
- Use an arithmetic function
- Use an aggregate function
- Making and querying annotations
- Use comparison operators with delta retrieval
- Use comparison operators with cyclic retrieval and cycle count
- Use comparison operators with cyclic retrieval and resolution
- Returning time between value changes
- Select into from a history table
- Moving data from a SQL server table to an extension table
- Use server-side cursors
- Use stored procedures in OLE DB queries
- Getting data from the OPCQualityMap table
- Using variables with the wide table
- Retrieval across a data gap in classically stored data
- Returned values for non-valid start times
- Querying aggregate data in different ways
- Bitwise retrieval for process data