# Historian help needed

**URL:** <https://forum.inductiveautomation.com/t/historian-help-needed/51281>\
**Category:** Ignition\
**Created:** [September 23, 2021, 7:16pm UTC](https://forum.inductiveautomation.com/t/historian-help-needed/51281 "2021-09-23T19:16:24Z")\
**Posts on this page:** 1\
**Showing post:** 29

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [November 22, 2021, 3:29pm UTC](https://forum.inductiveautomation.com/t/historian-help-needed/51281/29 "2021-11-22T15:29:11Z")

</div>

thanks

Simulation Aids is on my local.  
The datasets I need to work on are on production, and I am not authorized to add modules to the gateway or add resources from exchange to the project.

* * *

I didn't know `Partition By` was a thing in queries.  
I also need to read up on lead and lag.

> [@Calculating Total Time in Seconds](https://forum.inductiveautomation.com/t/calculating-total-time-in-seconds/49322/4):
>
> I usually do all of this in the database with lead() and/or lag() window functions. Say you have multiple of these recording to a single table, using an id column to segregate them. You record every change, and due to tag restarts or script restarts you get some duplicate rows as you’ve shown. The query to pick out all of the completed cycles that overlap a time period would be something like this: Select id, t\_stamp, finish\_ts, finish\_ts - t\_stamp As duration From ( Select id, t\_st…

This thread was linked early in this thread, and I like your post on it.  
I think I need to implement that kind of query.

* * *

I don't think a tag historian binding has "partition by" functionality.  
I think for this fault code , I have to use the transaction group since I can't add the resource that you made.

---

_[View the full topic](https://forum.inductiveautomation.com/t/historian-help-needed/51281)._
