WHERE Clause

Use the WHERE clause to further restrict the number of records that are retrieved from the database to only those that are of interest. The clause typically takes the form of one or more ‘conditions’. Only those records that meet one or more of the conditions are retrieved from the specified database table.

Example:

A List that displays only those points that are associated with a particular outstation, might use this type of syntax within its SELECT query:

FROM
CDBPOINT
WHERE
"SourceName" = 'My Group.My Outstation'

A List that displays only those database items that are associated with a particular group, might use this type of syntax within its SELECT query:

FROM
CDBOBJECT
WHERE
"~FullName" LIKE 'My Group.%'

(The % is a ‘wildcard’ used to denote a variable number of characters. (The wildcard to denote a single unknown character is an underscore (_).)

When querying the CDBEventJournal, CDBHistoric, CDBHistoricAll, or CForecastHistoric tables, you must specify a time constraint, to restrict the entries in the query result to those that occurred within a particular time period. Such a result might include this type of syntax within its SELECT query:

FROM
CDBEVENTJOURNAL
WHERE
"~RecordTime" BETWEEN { OPC 'H-23H' } AND { OPC 'H+1H' }

Additionally, when querying the CDBHistoric, CDBHistoricAll, or CForecastHistoric tables, you must constrain the query result to those records that are associated with an individual database item (either a particular point, accumulator, or forecast).

Whenever an alias is assigned to a field (see SELECT Clause), remember to specify that alias, rather than the field name, in the WHERE clause.


Disclaimer

ClearSCADA 2017 R3