# Query help sql date range between grouping 7am to 7am

**URL:** <https://forum.inductiveautomation.com/t/query-help-sql-date-range-between-grouping-7am-to-7am/59315>\
**Category:** Ignition\
**Created:** [May 6, 2022, 6:33pm UTC](https://forum.inductiveautomation.com/t/query-help-sql-date-range-between-grouping-7am-to-7am/59315 "2022-05-06T18:33:42Z")\
**Posts on this page:** 1\
**Showing post:** 18

<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:** [May 11, 2022, 1:56pm UTC](https://forum.inductiveautomation.com/t/query-help-sql-date-range-between-grouping-7am-to-7am/59315/18 "2022-05-11T13:56:08Z")

</div>

I need to join the query I worked on from this thread to the one you helped me with in another thread  
[here](https://forum.inductiveautomation.com/t/calculating-total-time-in-seconds/49322/71)

As much as the duration query looks at t\_stamp, when I join it, I can still join on t\_stamp, and the duration query’s references to t\_stamp for getting time won’t be impacted?  
Or do i join on like machine name, and then will that mean references to like durationTable.t\_stamp will not be impacted?  
The queries are so big, that it is hard for me to retain how they are in my mind.

I join on the inner most table?

so far my attempts to join have been unsuccessful like not compiling

or is there a way to join the tables on `format(dateadd(hh,-8, t_stamp), 'yyyy-MMM-dd')`

like joining on a subquery, is it a thing you can do?

* * *

I thought recursion was to code fast at the cost of efficiency, and should be avoided.

---

_[View the full topic](https://forum.inductiveautomation.com/t/query-help-sql-date-range-between-grouping-7am-to-7am/59315)._
