# Compare Columns Across Multiple Query Executions Using DQL

**URL:** <https://community.dynatrace.com/t/compare-columns-across-multiple-query-executions-using-dql/49281>\
**Category:** DQL\
**Tags:** dql\
**Created:** [December 10, 2024, 9:58am UTC](https://community.dynatrace.com/t/compare-columns-across-multiple-query-executions-using-dql/49281 "2024-12-10T09:58:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rseibert1](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@rseibert1](https://community.dynatrace.com/u/rseibert1)\
**Post date:** [December 10, 2024, 9:58am UTC](https://community.dynatrace.com/t/compare-columns-across-multiple-query-executions-using-dql/49281/1 "2024-12-10T09:58:09Z")

</div>

I have a workflow that has the below DQL task, I want to run and compare executions of this and create a list (of new unhealthy workers).

fetch logs  
| filter contains(log.tag, “octopus\_workers”)  
| parse content, “JSON:json”  
| fieldsFlatten json  
| expand json.content  
| fieldsFlatten json.content  
| expand json.content.alertText  
| fieldsFlatten json.content.alertText  
| fields timestamp, Id=json.content.alertText.Id

The table looks like:

 ![rseibert1_0-1733824360988.png](https://global.discourse-cdn.com/dynatrace/original/2X/e/e4fe9a69407485ffa5147d164837fd8006243612.png)

The timestamps are only currently ever 12hrs, (via the task that ingests the logs) but I will eventually ingest logs&nbsp; every 5min from workflow.

So the ability to compare Id’s from previous 5min and capture Ids that are recently added.

---

<div class="post-metadata">

**Author:** ![rseibert1](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@rseibert1](https://community.dynatrace.com/u/rseibert1)\
**Post date:** [December 13, 2024, 3:16pm UTC](https://community.dynatrace.com/t/compare-columns-across-multiple-query-executions-using-dql/49281/2 "2024-12-13T15:16:14Z")

</div>

Think maybe more than one way to do this, looking for the simplest, think if it ingests logs every 5min, I could compare the Id column from one execution to another and grab any unique ones. OR could make one DQL query that compares logs from the different times (now and -5min) but not having luck finding any examples of what I want to do.

Thanks

---

<div class="post-metadata">

**Author:** ![izabelarokita](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/izabelarokita/32/41812_2.png) [@izabelarokita](https://community.dynatrace.com/u/izabelarokita)\
**Post date:** [December 18, 2025, 12:52pm UTC](https://community.dynatrace.com/t/compare-columns-across-multiple-query-executions-using-dql/49281/3 "2025-12-18T12:52:32Z")

</div>

Hey&nbsp;[@rseibert1](https://community.dynatrace.com/user/77155)&nbsp;,  
I just wanted to check in and see if you still need help with this. If so, I’d be happy to look into it for you!&nbsp;:blush:  
Please let me know what works best for you.

---

<div class="post-metadata">

**Author:** ![t\_pawlak](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/t_pawlak/32/14991_2.png) [@t\_pawlak](https://community.dynatrace.com/u/t_pawlak)\
**Post date:** [December 18, 2025, 2:03pm UTC](https://community.dynatrace.com/t/compare-columns-across-multiple-query-executions-using-dql/49281/4 "2025-12-18T14:03:28Z")

</div>

Hi,  
You can do it in one DQL query by splitting the last 10 minutes into two windows (current 5m vs previous 5m) and returning only IDs that appear in the current window but not in the previous one.

```markup
fetch logs
| filter contains(log.tag, "octopus_workers")
| filter timestamp >= now() - 10m
| parse content, "JSON:json"
| expand json.content
| expand json.content.alertText
| fields ts = timestamp, Id = json.content.alertText.Id
| fieldsAdd window = if(ts >= now() - 5m, "curr", else: "prev")
| summarize
    in_curr = sum(if(window == "curr", 1, else: 0)),
    in_prev = sum(if(window == "prev", 1, else: 0)),
    first_seen = min(ts),
    last_seen = max(ts),
    by:{Id}
| filter in_curr > 0 and in_prev == 0
| fields Id, first_seen, last_seen
| sort last_seen desc

```
