Home : Products : Hach WIMS : Interfaces : Hach WIMS Direct Server-Side Interface to ClearSCADA System : Documentation : Topics specific to the operation of this interface : Sample SQL Queries
Q13584 - INFO: Sample SQL Queries

You can run SQL Queries against the ClearSCADA using the Hach WIMS SQL Console, or using ClearSCADA's ViewX application. To use the SQL Console, you will need the connection string first. Run the interface and select the menu option Configure > Source Configuration:

Click on the View Connection button, answer Yes to see the password, and then copy the text in the message box that appears on your screen:

Now run the application SQL_Console.exe found under the Hach WIMS Client folder, and select OLEDB source and paste the connection string in the text box below:

In the application text box, enter any of the following queries, changing the date range in the BETWEEN clause or the full tag name FullName='this tag name'. The interface will provide queries in its' log files when you turn the verbosity to level 3 or higher.

Average:
SELECT AVG(CurrentValueAsReal)
FROM CDBPoint, CDBHistoric
WHERE CDBPoint.ID=CDBHistoric.ID and
FullName='Sheboygan WWTP.I-O Points.RWW.Wetwell Level'
and (Recordtime BETWEEN{ts '2011-10-01 00:00:00'} AND {ts '2011-10-02 00:00:00'}) and
CurrentValueAsVariant is not null

Minimum:
SELECT MIN(CurrentValueAsReal)
FROM CDBPoint, CDBHistoric
WHERE CDBPoint.ID=CDBHistoric.ID and
FullName='Sheboygan WWTP.I-O Points.RWW.Wetwell Level'
and (Recordtime BETWEEN{ts '2011-10-01 00:00:00'} AND {ts '2011-10-02 00:00:00'}) and
CurrentValueAsVariant is not null

Maximum:
SELECT MAX(CurrentValueAsReal)
FROM CDBPoint, CDBHistoric
WHERE CDBPoint.ID=CDBHistoric.ID and
FullName='Sheboygan WWTP.I-O Points.RWW.Wetwell Level'
and (Recordtime BETWEEN{ts '2011-10-01 00:00:00'} AND {ts '2011-10-02 00:00:00'}) and
CurrentValueAsVariant is not null

First:
SELECT TOP (1) Recordtime, CurrentValueAsReal
FROM CDBPoint, CDBHistoric
WHERE CDBPoint.ID=CDBHistoric.ID and
FullName='Sheboygan WWTP.I-O Points.RWW.Wetwell Level'
and (Recordtime BETWEEN{ts '2011-10-01 00:00:00'} AND {ts '2011-10-02 00:00:00'}) and
CurrentValueAsVariant is not null order by Recordtime ASC

Last:
SELECT TOP (1) Recordtime, CurrentValueAsReal
FROM CDBPoint, CDBHistoric
WHERE CDBPoint.ID=CDBHistoric.ID and
FullName='Sheboygan WWTP.I-O Points.RWW.Wetwell Level'
and (Recordtime BETWEEN{ts '2011-10-01 00:00:00'} AND {ts '2011-10-02 00:00:00'}) and
CurrentValueAsVariant is not null order by Recordtime DESC

Total:
SELECT SUM(CurrentValueAsReal)
FROM CDBPoint, CDBHistoric
WHERE CDBPoint.ID=CDBHistoric.ID and
FullName='Sheboygan WWTP.I-O Points.RWW.Wetwell Level'
and (Recordtime BETWEEN{ts '2011-10-01 00:00:00'} AND {ts '2011-10-02 00:00:00'}) and
CurrentValueAsVariant is not null

 

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 10/6/2011 4:03 PM.
Last Modified on 10/7/2011 8:21 AM.
Last Modified by No Author Name Available!.
Article has been viewed 7205 times.
Rated 6 out of 10 based on 6 votes.
Print Article
Email Article