# SQL Report question - breaking data into batches or cycles

**URL:** <https://forum.inductiveautomation.com/t/sql-report-question-breaking-data-into-batches-or-cycles/86762>\
**Category:** Ignition\
**Tags:** database, reporting\
**Created:** [March 4, 2024, 2:57pm UTC](https://forum.inductiveautomation.com/t/sql-report-question-breaking-data-into-batches-or-cycles/86762 "2024-03-04T14:57:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keith\_Magill](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@Keith\_Magill](https://forum.inductiveautomation.com/u/Keith_Magill)\
**Post date:** [March 4, 2024, 2:57pm UTC](https://forum.inductiveautomation.com/t/sql-report-question-breaking-data-into-batches-or-cycles/86762/1 "2024-03-04T14:57:31Z")

</div>

Hello All,

I , like many control programmers who are well versed in the glory of Ladders code and PLC programming have a bit of a learning curve to the SQL query methodology.

While creating reports using continuous data trends is somewhat straight forward I am at a loss as to how to break these trends down into individual "Batches" or "Cycles. While the triggered data settings in the Transaction groups makes quick work of focusing the data into segmented "groups" how does one set-up up a report to find and populate a report based on these "chunks" of data?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 4, 2024, 4:47pm UTC](https://forum.inductiveautomation.com/t/sql-report-question-breaking-data-into-batches-or-cycles/86762/2 "2024-03-04T16:47:20Z")

</div>

You generally need another query that supplies the boundaries between chunks as timestamps, then you can configure a nested query to get the data per chunk. You could then use an "unstructured" detail row of a table to hold the chart. Or use an outer table group for more options.

---

<div class="post-metadata">

**Author:** ![Keith\_Magill](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@Keith\_Magill](https://forum.inductiveautomation.com/u/Keith_Magill)\
**Post date:** [March 4, 2024, 5:57pm UTC](https://forum.inductiveautomation.com/t/sql-report-question-breaking-data-into-batches-or-cycles/86762/3 "2024-03-04T17:57:30Z")

</div>

Phil,  
Again. I am relatively new to SQL . Are you saying make a nested query that defines the "START" and "STOP" points and a second to pull process data?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 4, 2024, 6:27pm UTC](https://forum.inductiveautomation.com/t/sql-report-question-breaking-data-into-batches-or-cycles/86762/4 "2024-03-04T18:27:43Z")

</div>

Yes, two queries. The outer query constructs one row per chunk with start and stop timestamps (and captures whatever other meta-data about the chunk that you want to show in the table). The inner query uses the outer row's timestamps to query the process data within those bounds.

Then a table in the report can show the values from the outer query's columns directly, and a chart embedded in the unstructured row can reference the inner query's data key.

---

<div class="post-metadata">

**Author:** ![Keith\_Magill](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@Keith\_Magill](https://forum.inductiveautomation.com/u/Keith_Magill)\
**Post date:** [March 6, 2024, 10:34pm UTC](https://forum.inductiveautomation.com/t/sql-report-question-breaking-data-into-batches-or-cycles/86762/5 "2024-03-06T22:34:30Z")

</div>

Phil,

Is there any "examples" to this approach. Like I said, I am in the SQL learning process.  
Just something that demonstrates the structure.

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 6, 2024, 10:55pm UTC](https://forum.inductiveautomation.com/t/sql-report-question-breaking-data-into-batches-or-cycles/86762/6 "2024-03-06T22:55:55Z")

</div>

Right in the manual, with links to IU videos:

> **[Nested Queries | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/reporting/report-data/nested-queries)**
>
> What are Nested Queries?

Note in particular how the SQL for the "Frequency" nested query uses a parameter supplied by each row of the "Codes" query.

And:

> **[Table Groups | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/reporting/report-design/report-table/table-groups)**
>
> Table groups are a single component that contains many tables, each with its own unique data. There are two types of Table Groups you can create within a Table component: Peer Tables and Child Tables. Peer Table Groups allow the second table to begin...
