# Query for Min and Max values and the time for report

**URL:** <https://forum.inductiveautomation.com/t/query-for-min-and-max-values-and-the-time-for-report/32077>\
**Category:** Ignition\
**Created:** [February 10, 2020, 12:04am UTC](https://forum.inductiveautomation.com/t/query-for-min-and-max-values-and-the-time-for-report/32077 "2020-02-10T00:04:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastian.zanotto](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@sebastian.zanotto](https://forum.inductiveautomation.com/u/sebastian.zanotto)\
**Post date:** [February 10, 2020, 12:04am UTC](https://forum.inductiveautomation.com/t/query-for-min-and-max-values-and-the-time-for-report/32077/1 "2020-02-10T00:04:30Z")

</div>

Hello,

I need to query for the min and max and there time stamp from tag history between the StartDate and EndDate of the report.

Thanks for any help

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [February 10, 2020, 1:48pm UTC](https://forum.inductiveautomation.com/t/query-for-min-and-max-values-and-the-time-for-report/32077/2 "2020-02-10T13:48:20Z")

</div>

Fill in your column name, your table name, the name of your time stamp column. The ? will bring up parameter boxes at the bottom to insert your report parameters in the format {StartDate} and {EndDate}

```auto
SELECT max(myColumn), min(myColumn) 
FROM myTable
where t_stamp between ? and ?

```

**EDIT** I missed your part about it being tag history. when you press the + button to add a data source, it should have an option for Tag Historian.

---

<div class="post-metadata">

**Author:** ![sebastian.zanotto](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@sebastian.zanotto](https://forum.inductiveautomation.com/u/sebastian.zanotto)\
**Post date:** [February 10, 2020, 9:21pm UTC](https://forum.inductiveautomation.com/t/query-for-min-and-max-values-and-the-time-for-report/32077/3 "2020-02-10T21:21:52Z")

</div>

Sorry so I already have a table that uses tag historian, I just want to be able to display the min and max values from this table separately

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [February 10, 2020, 9:28pm UTC](https://forum.inductiveautomation.com/t/query-for-min-and-max-values-and-the-time-for-report/32077/4 "2020-02-10T21:28:43Z")

</div>

Try looking in your data panel on left side of the design window. Try selecting ‘show calculations’, then look at your tag history data source it should have max, min, total, etc.

---

<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:** [February 10, 2020, 9:41pm UTC](https://forum.inductiveautomation.com/t/query-for-min-and-max-values-and-the-time-for-report/32077/5 "2020-02-10T21:41:56Z")

</div>

Use a script data source. Since you already have the raw data (if I understood correctly), you just need to extract the value column as a list, then pass that list to the python builtin `min` and `max` functions. Place the results in the `data` dictionary under keys of their own.

---

<div class="post-metadata">

**Author:** ![sebastian.zanotto](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@sebastian.zanotto](https://forum.inductiveautomation.com/u/sebastian.zanotto)\
**Post date:** [February 10, 2020, 10:07pm UTC](https://forum.inductiveautomation.com/t/query-for-min-and-max-values-and-the-time-for-report/32077/6 "2020-02-10T22:07:37Z")

</div>

This works however i need it to also show the timestamp for when it reached the min and max values
