# Alarm Query Assistance

**URL:** <https://forum.inductiveautomation.com/t/alarm-query-assistance/103930>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [March 20, 2025, 8:19am UTC](https://forum.inductiveautomation.com/t/alarm-query-assistance/103930 "2025-03-20T08:19:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samueldale](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Samueldale](https://forum.inductiveautomation.com/u/Samueldale)\
**Post date:** [March 20, 2025, 8:19am UTC](https://forum.inductiveautomation.com/t/alarm-query-assistance/103930/1 "2025-03-20T08:19:47Z")

</div>

Hi all,

Hoping someone can assist me with some scripting to query our alarm table.

Basically we have alarm groups & I can put them into a table with the following query;

```python
*"-- Select only distinct Equipment*

*SELECT DISTINCT alarm_event_data.strvalue*
*FROM alarm_event_data*
*WHERE alarm_event_data.propname = 'Equipment';"*

```

This will deliver a table with 1 row and x columns e.g

Alarm Group 0  
Alarm Group 1  
Alarm Group 2  
........ 12

Now the part I'm struggling with is; I would like an expression that will query this table and return the number of active alarms in a specific equipment group I am querying as an integer. Or even as a dataset showing group/event\_count.

Might be asking a bit much here but any help would be appreciated.  
Cheers,

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 20, 2025, 2:44pm UTC](https://forum.inductiveautomation.com/t/alarm-query-assistance/103930/2 "2025-03-20T14:44:30Z")

</div>

As written, this is purely a SQL question, and the answer is to use aggregation:

```sql
SELECT 
    aed.strvalue, 
    count(aed.id)
FROM alarm_event_data aed
WHERE aed.propname = 'Equipment'
GROUP BY alarm_event_data.strvalue

```

This will return a two column dataset with group name and count.

---

<div class="post-metadata">

**Author:** ![Samueldale](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Samueldale](https://forum.inductiveautomation.com/u/Samueldale)\
**Post date:** [March 20, 2025, 8:55pm UTC](https://forum.inductiveautomation.com/t/alarm-query-assistance/103930/3 "2025-03-20T20:55:17Z")

</div>

Thanks for the reply. Could you take a look at the attached pic and tell me what I missed?

 ![Alarmquery](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/e/7e7d5803223d81b16d6591f9c292cedb6fde33a7.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 20, 2025, 9:57pm UTC](https://forum.inductiveautomation.com/t/alarm-query-assistance/103930/4 "2025-03-20T21:57:52Z")

</div>

If you hover over 'Error\_Configuration' what does it say?  
You might need to change your return format to `JSON`, and it may need a transform or adjustment in your query to line up with the format the radar chart expects to display.

---

<div class="post-metadata">

**Author:** ![Samueldale](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Samueldale](https://forum.inductiveautomation.com/u/Samueldale)\
**Post date:** [March 21, 2025, 12:13am UTC](https://forum.inductiveautomation.com/t/alarm-query-assistance/103930/5 "2025-03-21T00:13:11Z")

</div>

Yeah I was aware that if it's in a dataset I'll need to transform to get the required column/row as I need a real number at the end, however I don't think that's the issue here. Below is the error details;

> com.microsoft.sqlserver.jdbc.SQLServerException: The multi-part identifier "alarm\_event\_data.strvalue" could not be bound.

Here is a query currently in use to query total alarm counts within a time period if that helps;

```python
SELECT 
    DATEADD(hour, DATEDIFF(hour, 0, alarm_events.eventtime), 0) AS hour_start,
    COUNT(*) AS alarm_count
FROM 
    alarm_event_data
INNER JOIN 
    alarm_events ON alarm_event_data.id = alarm_events.id
WHERE 
    alarm_event_data.propname = 'label'
    AND alarm_events.eventtime >= DATEADD(HOUR, :timePeriod, GETDATE()) -- Filter alarms within the last 8 hours
    AND alarm_events.eventtype = 0
GROUP BY 
    DATEADD(hour, DATEDIFF(hour, 0, alarm_events.eventtime), 0)
ORDER BY 
    hour_start;

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 21, 2025, 12:24am UTC](https://forum.inductiveautomation.com/t/alarm-query-assistance/103930/6 "2025-03-21T00:24:50Z")

</div>

![Missing query params](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/4/947217f89096e0b5d55bf92df419ee5b2b1974cf.png)

Are you missing the query parameters?

Tip: resize windows before taking a screengrab. Yours is 50% whitespace. Often the reduction in size means they are displayed at 100% and avoids an extra step in reading your post and flipping between the post and a 100% popup.
