# Calculating Total Time in Seconds

**URL:** <https://forum.inductiveautomation.com/t/calculating-total-time-in-seconds/49322>\
**Category:** Ignition\
**Created:** [July 28, 2021, 6:44pm UTC](https://forum.inductiveautomation.com/t/calculating-total-time-in-seconds/49322 "2021-07-28T18:44:54Z")\
**Posts on this page:** 1\
**Showing post:** 56

<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:** [December 2, 2021, 7:04pm UTC](https://forum.inductiveautomation.com/t/calculating-total-time-in-seconds/49322/56 "2021-12-02T19:04:24Z")

</div>

> [@Organizing SQL tables and named queries efficiently](https://forum.inductiveautomation.com/t/organizing-sql-tables-and-named-queries-efficiently/53212/13):
>
> Event logs are the poster child for “tall” tables. So, option 1, unquestionably. For efficiency, I would use a numeric foreign key for machine, where a separate, relatively static table of machines has that as a primary key. I would also omit duration, as it is easily generated from lead(t\_stamp) over (partition by machine order by t\_stamp).

When you said easily generated, did you mean there is an easier way to get the time between timestamps and sum them up?

Or did you mean a query similar to discussed here used with  
` lead(t_stamp) over (partition by machine order by t_stamp)`  
to omit other machines if the table has many machines

---

_[View the full topic](https://forum.inductiveautomation.com/t/calculating-total-time-in-seconds/49322)._
