Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

Join our "Ask Me About" community webinar on May 20th at 9 AM CET and 5 PM CET to explore cybersecurity and monitoring for Data Center and edge IT. Learn about market trends, cutting-edge technologies, and best practices from industry experts.
Register and secure your Critical IT infrastructure

Aggregate by string concatenation in SQL (Geo SCADA 2020)

EcoStruxure Geo SCADA Expert Forum

Schneider Electric support forum about installation, configuration, integration and troubleshooting of EcoStruxure Geo SCADA Expert (ClearSCADA, ViewX, WebX).

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Home
  • Schneider Electric Community
  • Remote Operations
  • EcoStruxure Geo SCADA Expert Forum
  • Aggregate by string concatenation in SQL (Geo SCADA 2020)
Options
  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
sbeadle
Kirk sbeadle Kirk
307
AndrewScott
Admiral AndrewScott
95
BevanWeiss
Spock BevanWeiss
89
AdamWoodlandToo
Lt. Commander AdamWoodlandToo
36
View All
Related Products
product field
Schneider Electric
EcoStruxure™ Geo SCADA Expert

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to EcoStruxure Geo SCADA Expert Forum
Solved
rlao
Lt. Commander rlao
Lt. Commander

Posted: ‎2022-02-23 06:36 PM . Last Modified: ‎2023-05-02 11:58 PM

0 Likes
3
1300
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2022-02-23 06:36 PM . Last Modified: ‎2023-05-02 11:58 PM

Aggregate by string concatenation in SQL (Geo SCADA 2020)

The SQL documentation only lists a few basic aggregation functions to be used with a GROUP BY statement. Unfortunately, the summarization I am after is to concatenate all the rows into a single string which does not appear to be supported.

 

Is there a way I can achieve this using other SQL expressions? Table in question is a dataset of <500 entries.

 

Thanks

Labels
  • Labels:
  • SCADA
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Reply

Link copied. Please paste this link to share this article on your social media post.

  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
BevanWeiss
Spock BevanWeiss
Spock

Posted: ‎2022-02-24 03:56 PM

0 Likes
2
1284
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2022-02-24 03:56 PM

This isn't strictly a Geo SCADA Expert limitation so much as it is a limitation with the SQL-92 standard implementation used by Geo SCADA Expert (with some slight customisation for GIS / indirect operations).

 

You'll generally find that standard aggregates will only be operations that are commutative.  That is the order of the arguments is independent to the result.  i.e. if I have three values, RowA, RowB, and RowC.. and do a SUM(Row...), AVG(Row..), MIN(Row..), MAX(Row..), SDEV(Row..), VAR(Row..) it is the same regardless of the order of the operands.  i.e. if I swap the RowA and RowC values the aggregate is identical.  This is important, because in SQL you are not guaranteed any given ordering of the result set unless you specifically request it with an ORDER BY clause.  And this is only guaranteed to operate on the actual result set provided, not any intermediate data required to generate the result set.  As such CONCATENATE(...) simply can't be a valid aggregate, since CONCATENATE(RowA, RowB, RowC) is different than CONCATENATE(RowB, RowA, RowC).. and hence it's simply too problematic 

 

In general it's not well supported within SQL syntax, even proprietary vendor syntax.

MS SQL Server only recently supported it with STRING_AGGR.

 

The most common way to handle this in other SQL-like products would be to use a CURSOR, and index through the result set using a variable to hold the concatenation result.  Unfortunately Geo SCADA Expert doesn't support such use of CURSORs.  It also doesn't support recursive Common Table Expressions, which is an alternative method to support similar.

You could try something like this: https://stackoverflow.com/a/17308646/2535822 

But as noted in the stackoverflow post, CTEs weren't supported by SQL-92, and so it's very unlikely to work in Geo SCADA Expert. 

 

I would say that your best option here may be the use of ST Logic.  Which obviously imposes some additional limitations that wouldn't be in an SQL pure implementation (i.e. you'd want it to be calculated ahead of time, you'd need to store it somewhere, and due to both of these, it couldn't be as dynamic or adhoc user driven).
You could do the concat within Mimic scripting if you wanted more of the adhoc user driven stuff, but it would be cludgey to couple it back to the remainder of your SQL results.

Something like
ServerQuery(... to get all the rows that you want to concatenate)

for each row in Serverquery result

  strConcatenated = strConcatenated + "," + row.columntoconcat

endfor

 

ServerQuery( "SELECT " + strConcatenated + ", col2, etc FROM stuff WHERE thing=thatThingILike" )

 

If you wanted it to be an embedded query shown, you could have the script execute on Mimic_Navigate or something like that, and instead of the second ServerQuery it would write to the SQL property of the EmbeddedQuery object

i.e. Layers("Layer").Items("Item").SQL = "SELECT " + strConcatenated + ", col2, etc FROM... blurgh"

It still wouldn't be super dynamic though, the concatenated result wouldn't update automatically..


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..

See Answer In Context

  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Reply

Link copied. Please paste this link to share this article on your social media post.

Replies 3
BevanWeiss
Spock BevanWeiss
Spock

Posted: ‎2022-02-24 03:56 PM

0 Likes
2
1285
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2022-02-24 03:56 PM

This isn't strictly a Geo SCADA Expert limitation so much as it is a limitation with the SQL-92 standard implementation used by Geo SCADA Expert (with some slight customisation for GIS / indirect operations).

 

You'll generally find that standard aggregates will only be operations that are commutative.  That is the order of the arguments is independent to the result.  i.e. if I have three values, RowA, RowB, and RowC.. and do a SUM(Row...), AVG(Row..), MIN(Row..), MAX(Row..), SDEV(Row..), VAR(Row..) it is the same regardless of the order of the operands.  i.e. if I swap the RowA and RowC values the aggregate is identical.  This is important, because in SQL you are not guaranteed any given ordering of the result set unless you specifically request it with an ORDER BY clause.  And this is only guaranteed to operate on the actual result set provided, not any intermediate data required to generate the result set.  As such CONCATENATE(...) simply can't be a valid aggregate, since CONCATENATE(RowA, RowB, RowC) is different than CONCATENATE(RowB, RowA, RowC).. and hence it's simply too problematic 

 

In general it's not well supported within SQL syntax, even proprietary vendor syntax.

MS SQL Server only recently supported it with STRING_AGGR.

 

The most common way to handle this in other SQL-like products would be to use a CURSOR, and index through the result set using a variable to hold the concatenation result.  Unfortunately Geo SCADA Expert doesn't support such use of CURSORs.  It also doesn't support recursive Common Table Expressions, which is an alternative method to support similar.

You could try something like this: https://stackoverflow.com/a/17308646/2535822 

But as noted in the stackoverflow post, CTEs weren't supported by SQL-92, and so it's very unlikely to work in Geo SCADA Expert. 

 

I would say that your best option here may be the use of ST Logic.  Which obviously imposes some additional limitations that wouldn't be in an SQL pure implementation (i.e. you'd want it to be calculated ahead of time, you'd need to store it somewhere, and due to both of these, it couldn't be as dynamic or adhoc user driven).
You could do the concat within Mimic scripting if you wanted more of the adhoc user driven stuff, but it would be cludgey to couple it back to the remainder of your SQL results.

Something like
ServerQuery(... to get all the rows that you want to concatenate)

for each row in Serverquery result

  strConcatenated = strConcatenated + "," + row.columntoconcat

endfor

 

ServerQuery( "SELECT " + strConcatenated + ", col2, etc FROM stuff WHERE thing=thatThingILike" )

 

If you wanted it to be an embedded query shown, you could have the script execute on Mimic_Navigate or something like that, and instead of the second ServerQuery it would write to the SQL property of the EmbeddedQuery object

i.e. Layers("Layer").Items("Item").SQL = "SELECT " + strConcatenated + ", col2, etc FROM... blurgh"

It still wouldn't be super dynamic though, the concatenated result wouldn't update automatically..


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Reply

Link copied. Please paste this link to share this article on your social media post.

rlao
Lt. Commander rlao
Lt. Commander

Posted: ‎2022-02-28 07:43 PM

In response to BevanWeiss
1 Like
1
1271
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2022-02-28 07:43 PM

Thanks Bevan.

 

Yes you are right this seems to be more a SQL92 limitation, but I was hoping there was something vendor-specific that I had missed. However, you raised a good point regarding commutation that would probably make such an aggregate too messy to implement.

 

My alternate idea is the Mimic_Navigate solution you mentioned and loop through the query row to build the string. The lack of dynamic update while on the mimic page is not too much of a problem for me as the dataset shouldn't change that frequently over time. I just wanted to see if there was a more elegant solution I was missing.

  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Reply

Link copied. Please paste this link to share this article on your social media post.

BevanWeiss
Spock BevanWeiss
Spock

Posted: ‎2022-03-01 01:40 PM

In response to rlao
0 Likes
0
1260
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2022-03-01 01:40 PM

In regards to SQL standards, as mentioned Geo SCADA Expert is SQL-92 (with some minor proprietary additions).

Since this 1992 standard release, the following more recent standard revisions have been released:

  • 1996
  • 1999
  • 2003
  • 2006
  • 2008
  • 2011
  • 2016
  • 2019

Many of the latter standards have quite niche enhancements, i.e. 2003 introduced XML, 2016 introduced JSON

The 1999 standard however introduced Common Table Expressions (CTEs), which would have helped you to perform the query you were after.

 

I'm unsure exactly how coupled the current SQL Query Parser is to the core of the Geo SCADA Expert system, but it might be worthwhile raising a feature request for an update of the supported syntax version (i.e. from SQL-92 up to SQL-99 or perhaps even more recent versions with JSON support etc).


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Reply

Link copied. Please paste this link to share this article on your social media post.

Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

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.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of