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

Finging object wich caused last alarm

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
  • Finging object wich caused last alarm
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
96
BevanWeiss
Spock BevanWeiss
90
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
IgorSivakov
Lieutenant IgorSivakov
Lieutenant

Posted: ‎2021-07-12 12:56 AM . Last Modified: ‎2023-05-03 12:02 AM

0 Likes
9
2333
  • 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: ‎2021-07-12 12:56 AM . Last Modified: ‎2023-05-03 12:02 AM

Finging object wich caused last alarm

Is there a way to find and object in a group, which caused last alarm? I need to display some data on this object for more than 100 plants, so I want to do this in one SQL-query

Labels
  • Labels:
  • ViewX
  • 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
IgorSivakov
Lieutenant IgorSivakov
Lieutenant

Posted: ‎2021-07-13 10:16 PM

In response to AdamWoodland
0 Likes
0
2300
  • 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: ‎2021-07-13 10:16 PM

It's not quite what I wanted, because I need a list of plants with active alarms. Anyway, our IT department helped me with this task and it's most complicated query I've erer saw. It still has one flaw - if two alarms in one group happened in exact same moment, query will return multiple rows on than group, but it's fine by me. 

SELECT 
    Query.ID,
    DISTINCT(Query.Name),
    Query.AlarmState,
    Query.AlarmLastUpdateTime,
    Query.AlarmId,
    Query.Message,
    Query.FullName,
    Query.MaxSubConditionActiveTime
FROM (
    SELECT 
        FilteredGroup.Id AS ID,
        FilteredGroup.Name,
        FilteredGroup.AlarmState,
        FilteredGroup.AlarmLastUpdateTime,
        CAlarm.Id AS AlarmId,
        CAlarm.Message,
        MaxObject.FullName,
        MaxObject.MaxSubConditionActiveTime
    FROM (
        SELECT
            CGroup.ID,
            CGroup.Name,
            CGroup.AlarmState,
            CGroup.AlarmLastUpdateTime
        FROM CGroup 
        WHERE
            CGroup.AlarmState > 0
            AND CGroup.Name LIKE '%ВНС%'
            AND CGroup.Name NOT LIKE '%(с)%'
    ) FilteredGroup
    JOIN (
        SELECT
            CDBObject.ID,
            MAX(CAlarm.SubConditionActiveTime) as MaxSubConditionActiveTime,
            CDBObject.Fullname
        FROM CAlarm
        JOIN CDBObject
            ON CDBObject.Id = CAlarm.Id
        WHERE
            CAlarm.Message <> ''
        GROUP BY
            CDBObject.ID,
            CDBObject.FullName
    ) AS MaxObject ON FullName LIKE '%' || FilteredGroup.Name || '%'
    JOIN CAlarm
        ON MaxObject.Id = CAlarm.Id
        AND MaxObject.MaxSubConditionActiveTime = CAlarm.SubConditionActiveTime
) Query
JOIN (
    SELECT 
        FilteredGroup.Id,
        MAX(MaxObject.MaxSubConditionActiveTime) AS MaxSubConditionActiveTime
    FROM (
        SELECT
            CGroup.ID,
            CGroup.Name
        FROM CGroup 
        WHERE
            CGroup.AlarmState > 0
            AND CGroup.Name LIKE '%ВНС%'
            AND CGroup.Name NOT LIKE '%(с)%'
    ) FilteredGroup
    JOIN (
        SELECT
            CDBObject.ID,
            MAX(CAlarm.SubConditionActiveTime) as MaxSubConditionActiveTime,
            CDBObject.Fullname
        FROM CAlarm
        JOIN CDBObject
            ON CDBObject.Id = CAlarm.Id
        WHERE
            CAlarm.Message <> ''
        GROUP BY
            CDBObject.ID,
            CDBObject.FullName
    ) AS MaxObject ON FullName LIKE '%' || FilteredGroup.Name || '%'
    JOIN CAlarm
        ON MaxObject.Id = CAlarm.Id
        AND MaxObject.MaxSubConditionActiveTime = CAlarm.SubConditionActiveTime
    GROUP BY FilteredGroup.Id
) AnnotatedQuery
    ON Query.Id = AnnotatedQuery.Id
    AND Query.MaxSubConditionActiveTime = AnnotatedQuery.MaxSubConditionActiveTime
ORDER BY Query.ID, Query.MaxSubConditionActiveTime DESC

 

Condition to filter groups (lines 29-30 and 60-61): 

CGroup.Name LIKE '%ВНС%'
AND CGroup.Name NOT LIKE '%(с)%'

 

 

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 9
AdamWoodland
AdamWoodland Schneider Alumni (Retired)
Schneider Alumni (Retired)

Posted: ‎2021-07-12 04:03 PM

0 Likes
8
2322
  • 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: ‎2021-07-12 04:03 PM

The CAlarm table will be able to give you this info, just JOIN it with CAlarmObject to filter on FullName to the group you need, and then sort by the preferred column (and can do a TOP (1) for just the first row)

  • 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.

IgorSivakov
Lieutenant IgorSivakov
Lieutenant

Posted: ‎2021-07-12 09:58 PM

In response to AdamWoodland
0 Likes
7
2316
  • 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: ‎2021-07-12 09:58 PM

I can't quite understang how I should do this. 

For now, I have querry, which gives me list of plants with alarms. How can I join it with multiple queries, that return top(1) from CAlarm? My SQL knowledge is not so good, so I don't understand how it should work

 Q1.png

  • 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.

AdamWoodland
AdamWoodland Schneider Alumni (Retired)
Schneider Alumni (Retired)

Posted: ‎2021-07-13 07:09 PM

In response to IgorSivakov
0 Likes
6
2306
  • 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: ‎2021-07-13 07:09 PM

You'll want something like:

 

SELECT TOP( 1 )
	O.FULLNAME, A.SUBCONDITIONACTIVETIME
FROM
	CALARM AS "A" LEFT JOIN CALARMOBJECT AS "O" ON A.ID = O.ID
WHERE
	O.FULLNAME LIKE 'Test.%' AND (A.STATE = 4 OR A.STATE = 2)
ORDER BY
	"SubConditionActiveTime" DESC

 

It basically queries for the latest currently active (i.e. not cleared) alarm in the "Test" group. Note this might not be the latest alarm if another alarm was raised more recently and is already cleared. If you do need the most recent alarm to be active no matter what its current state is you'll have to use CAlarmSummary (or worse CDBEventJournal) but its a similar type of query.

  • 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.

IgorSivakov
Lieutenant IgorSivakov
Lieutenant

Posted: ‎2021-07-13 10:16 PM

In response to AdamWoodland
0 Likes
0
2301
  • 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: ‎2021-07-13 10:16 PM

It's not quite what I wanted, because I need a list of plants with active alarms. Anyway, our IT department helped me with this task and it's most complicated query I've erer saw. It still has one flaw - if two alarms in one group happened in exact same moment, query will return multiple rows on than group, but it's fine by me. 

SELECT 
    Query.ID,
    DISTINCT(Query.Name),
    Query.AlarmState,
    Query.AlarmLastUpdateTime,
    Query.AlarmId,
    Query.Message,
    Query.FullName,
    Query.MaxSubConditionActiveTime
FROM (
    SELECT 
        FilteredGroup.Id AS ID,
        FilteredGroup.Name,
        FilteredGroup.AlarmState,
        FilteredGroup.AlarmLastUpdateTime,
        CAlarm.Id AS AlarmId,
        CAlarm.Message,
        MaxObject.FullName,
        MaxObject.MaxSubConditionActiveTime
    FROM (
        SELECT
            CGroup.ID,
            CGroup.Name,
            CGroup.AlarmState,
            CGroup.AlarmLastUpdateTime
        FROM CGroup 
        WHERE
            CGroup.AlarmState > 0
            AND CGroup.Name LIKE '%ВНС%'
            AND CGroup.Name NOT LIKE '%(с)%'
    ) FilteredGroup
    JOIN (
        SELECT
            CDBObject.ID,
            MAX(CAlarm.SubConditionActiveTime) as MaxSubConditionActiveTime,
            CDBObject.Fullname
        FROM CAlarm
        JOIN CDBObject
            ON CDBObject.Id = CAlarm.Id
        WHERE
            CAlarm.Message <> ''
        GROUP BY
            CDBObject.ID,
            CDBObject.FullName
    ) AS MaxObject ON FullName LIKE '%' || FilteredGroup.Name || '%'
    JOIN CAlarm
        ON MaxObject.Id = CAlarm.Id
        AND MaxObject.MaxSubConditionActiveTime = CAlarm.SubConditionActiveTime
) Query
JOIN (
    SELECT 
        FilteredGroup.Id,
        MAX(MaxObject.MaxSubConditionActiveTime) AS MaxSubConditionActiveTime
    FROM (
        SELECT
            CGroup.ID,
            CGroup.Name
        FROM CGroup 
        WHERE
            CGroup.AlarmState > 0
            AND CGroup.Name LIKE '%ВНС%'
            AND CGroup.Name NOT LIKE '%(с)%'
    ) FilteredGroup
    JOIN (
        SELECT
            CDBObject.ID,
            MAX(CAlarm.SubConditionActiveTime) as MaxSubConditionActiveTime,
            CDBObject.Fullname
        FROM CAlarm
        JOIN CDBObject
            ON CDBObject.Id = CAlarm.Id
        WHERE
            CAlarm.Message <> ''
        GROUP BY
            CDBObject.ID,
            CDBObject.FullName
    ) AS MaxObject ON FullName LIKE '%' || FilteredGroup.Name || '%'
    JOIN CAlarm
        ON MaxObject.Id = CAlarm.Id
        AND MaxObject.MaxSubConditionActiveTime = CAlarm.SubConditionActiveTime
    GROUP BY FilteredGroup.Id
) AnnotatedQuery
    ON Query.Id = AnnotatedQuery.Id
    AND Query.MaxSubConditionActiveTime = AnnotatedQuery.MaxSubConditionActiveTime
ORDER BY Query.ID, Query.MaxSubConditionActiveTime DESC

 

Condition to filter groups (lines 29-30 and 60-61): 

CGroup.Name LIKE '%ВНС%'
AND CGroup.Name NOT LIKE '%(с)%'

 

 

  • 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: ‎2021-07-18 03:22 PM

In response to AdamWoodland
0 Likes
4
2266
  • 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: ‎2021-07-18 03:22 PM

Is the join needed?

Couldn't this work

 

SELECT TOP( 1 )
	ID->FULLNAME as "FullName", SUBCONDITIONACTIVETIME
FROM
	CALARM
WHERE
	ID->FULLNAME LIKE 'Test.%' AND (STATE = 4 OR STATE = 2)
ORDER BY
	SubConditionActiveTime DESC

 


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.

AdamWoodland
AdamWoodland Schneider Alumni (Retired)
Schneider Alumni (Retired)

Posted: ‎2021-07-18 10:00 PM

In response to BevanWeiss
0 Likes
3
2259
  • 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: ‎2021-07-18 10:00 PM

Yeah, you're right Bevan, CAlarm.Id is a reference to CAlarmObject so your version of the query will work and is more tidy. It is mostly laziness on my behalf and doing JOINs out of habit as things like the CDBEventJournal aren't a reference 🙂

 

Regarding Igor's query, CAlarm.Message <> '' may not be the best either, (A.STATE = 4 OR A.STATE = 2) might work better, or (A.State > 1) if that's what you're after. How much performance you get by tweaking some of those things are up to you and would depend on how frequently you run them. Play and see which performance works best for you and still gets you the relevant data.

  • 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.

IgorSivakov
Lieutenant IgorSivakov
Lieutenant

Posted: ‎2021-07-18 10:23 PM

In response to AdamWoodland
0 Likes
2
2256
  • 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: ‎2021-07-18 10:23 PM

As I said - I need a list of groups whith a name of an alarm object attached to each, so I can't just go with "select top(1) ...". My goal here is to get nesessary data for dispatcher's mimic. It's the same mimic, I asked about recently here Embedded list format

Now I just need to make my own alarm messages for it, and it will be quite a pain.

Anyway. thanks for commets, everyone!

  • 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.

geoffpatton
Captain geoffpatton
Captain

Posted: ‎2021-07-19 06:56 AM

In response to IgorSivakov
0 Likes
1
2253
  • 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: ‎2021-07-19 06:56 AM

For each plant You could run a Structured Text program that Queries the Top(1) for that plant and have it write to a Data Table.

Then Query the Data Table to show the most recent alarm of each plant.

 

Don't run your ST programs to often.

 

Calculation String Points may work instead of a Data Table. Then Query the String Points to show the most recent alarm of each plant.

  • 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: ‎2021-07-19 08:54 PM

In response to geoffpatton
0 Likes
0
2242
  • 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: ‎2021-07-19 08:54 PM

I'm not sure I'd go with ST Logic here.. since the performance wouldn't scale very well.  Having 100+ logic programs executing rapidly would really bring a system to its knees.

 

I probably would have gone with a nested query and a LEFT OUTER JOIN..

 

i.e. 

SELECT G.FullName
FROM CGroup AS G
LEFT OUTER JOIN
(
  SELECT TOP(1) ID->FullName, SubConditionActiveTime
  FROM CAlarm
  WHERE FullName LIKE G.FullName || '.%'
) AS A
WHERE G.ParentGroupName->FullName = 'Plants'

 

Not sure if my syntax is quite right here.. but something like this will work I'm sure..


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