# Postgres Query Help - Determine Unacked Events

**URL:** <https://forum.inductiveautomation.com/t/postgres-query-help-determine-unacked-events/91457>\
**Category:** Ignition\
**Created:** [June 6, 2024, 3:46am UTC](https://forum.inductiveautomation.com/t/postgres-query-help-determine-unacked-events/91457 "2024-06-06T03:46:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trevor\_Salewski](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@Trevor\_Salewski](https://forum.inductiveautomation.com/u/Trevor_Salewski)\
**Post date:** [June 6, 2024, 3:46am UTC](https://forum.inductiveautomation.com/t/postgres-query-help-determine-unacked-events/91457/1 "2024-06-06T03:46:31Z")

</div>

I'm try to write query that will allow me to see how many alarm events when unacknowledged using Postgres by comparing event types against event id's. I'd like to know how many event id's do not have an entry with an event type of 2. For example, the table below would return one event that went unacknowledged.

| eventid | eventtype |
| --- | --- |
| eventid1 | 1 |
| eventid1 | 0 |
| eventid2 | 2 |
| eventid2 | 0 |
| eventid2 | 1 |

Thanks in advance for any help.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 7, 2024, 6:20pm UTC](https://forum.inductiveautomation.com/t/postgres-query-help-determine-unacked-events/91457/2 "2024-06-07T18:20:41Z")

</div>

I was able to use a CROSSTAB() function in the query:

```SQL
SELECT *
FROM CROSSTAB('select eventid,
                      eventtype,
                      eventtype as value
                      FROM alarm_events
                      WHERE eventtype in (0,2)') AS CT (eventid varchar(255), "type0" int, "type2" int)
WHERE type2 IS NULL

```
