# SQL query to calculate Difference

**URL:** <https://forum.inductiveautomation.com/t/sql-query-to-calculate-difference/61807>\
**Category:** Ignition\
**Tags:** ignition81, namedqueries, scripting\
**Created:** [July 12, 2022, 5:00pm UTC](https://forum.inductiveautomation.com/t/sql-query-to-calculate-difference/61807 "2022-07-12T17:00:13Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [July 13, 2022, 4:13pm UTC](https://forum.inductiveautomation.com/t/sql-query-to-calculate-difference/61807/8 "2022-07-13T16:13:34Z")

</div>

You could also do this in scripting, something that may be helpful for you,

> [@Tag history difference over interval](https://forum.inductiveautomation.com/t/tag-history-difference-over-interval/48366):
>
> I am trying to find a better way to do production counts over specific intervals using tag history. Example, I have a tag TestCount, right now it’s a memory tag, but typically this would be an OPC tag from a PLC that increments. I can’t use Count aggregationMode because it may not “catch” each transition, example, it may go from 10 to 13. My desire is to be able to chart this data over a period of time, example, 12 hours, with a certain interval, example 1 hour. So, if at the start of the ho…

---

_[View the full topic](https://forum.inductiveautomation.com/t/sql-query-to-calculate-difference/61807)._
