Ask our Experts
Didn't find what you are looking for? Ask our experts!
Launch of Consumer/Home Owner registration process! We are pleased to announce the commencement of the Consumer/Home Owner Registration Process on Community. Consumers/Home Owners may now proceed to register by clicking on Login/Register. The process is straightforward and designed to be completed in just a few steps.
Schneider Electric support forum about installation, configuration, integration and troubleshooting of EcoStruxure Geo SCADA Expert (ClearSCADA, ViewX, WebX).
Search in
Link copied. Please paste this link to share this article on your social media post.
Posted: 2019-11-05 01:34 PM . Last Modified: 2023-05-03 12:34 AM
>>Message imported from previous forum - Category:ClearSCADA Software<<
User: florian, originally posted: 2018-10-25 17:04:06 Id:249
This is a re-posting from the obsoleted (October 2018) "Schneider Electric Telemetry & SCADA" forum.
-------------------------------
**_nminchin:_**
**_It's been a while since I've used ClearSCADA..._**
**_I'm trying to get a list of DNP3 AIs and BIs and their PointNumbers, so I've got the query:_**
_SELECT * FROM (SELECT ID, ID, FullName, PointNumber FROM CDNP3AnalogIn UNION SELECT ID, ID, FullName, PointNumber FROM CDNP3BinaryIn)_
_tmp_
_WHERE FullName LIKE 'Sites.%'_
**_however getting an error at the UNION area saying i'm missing a ')' at the first index.... I recall having to format this strangely years ago, but can't remember._**
**_Any ideas?_**
**_Cheers_**
**_Edit: putting the where clause inside both sub queries and removing the SELECT * FROM works, but if I had a more complex query, how would I do this?_**
-----------------
sbeadle:
The UNION keyword can be used in two ways:
1. To be the 'innermost' operation, 'merging tables', e.g.
_SELECT_
_ID, ID, FULLNAME, POINTNUMBER_
_FROM_
_CDNP3ANALOGIN UNION CDNP3ANALOGIN_
_WHERE_
_FULLNAME LIKE '%'_
For this to work the columns must all have the same names, which does work in your case.
2. to be the 'outermost' operation of two or more complete queries, with only an ORDER BY, but without any WHERE clauses:
_( SELECT ID, ID, FULLNAME, POINTNUMBER FROM CDNP3ANALOGIN WHERE FULLNAME LIKE '%' )_
_UNION_
_( SELECT ID, ID, FULLNAME, POINTNUMBER FROM CDNP3ANALOGIN WHERE FULLNAME LIKE '%' )_
_ORDER BY_
_"FullName" ASC_
Search help for SQL UNION and you can see the syntax.
This is in the Core Reference Coding SQL Guide
Steve
Link copied. Please paste this link to share this article on your social media post.
You’ve reached the end of your document
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.