# Search Historian with WHERE clause

**URL:** <https://forum.inductiveautomation.com/t/search-historian-with-where-clause/23541>\
**Category:** Ignition\
**Created:** [March 22, 2019, 5:10pm UTC](https://forum.inductiveautomation.com/t/search-historian-with-where-clause/23541 "2019-03-22T17:10:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimE](https://avatars.discourse-cdn.com/v4/letter/t/ee59a6/32.png) [@TimE](https://forum.inductiveautomation.com/u/TimE)\
**Post date:** [March 22, 2019, 5:10pm UTC](https://forum.inductiveautomation.com/t/search-historian-with-where-clause/23541/1 "2019-03-22T17:10:26Z")

</div>

I would like to be able to search for values in the historian that meet certain criteria, for example: all values for a given tag where the value is between a high and low limit. Is this possible with any of the built in tools?

Currently, I have a script that queries the historian and I loop through the result to extract the data I need. Just looking for a better way to do it.

Thanks,  
Tim

---

<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 23, 2019, 3:03pm UTC](https://forum.inductiveautomation.com/t/search-historian-with-where-clause/23541/2 "2019-03-23T15:03:11Z")

</div>

Not in the historian functions, no. If you need such stuff in a binding, you might like my [view()](https://www.automation-pros.com/simaids/doc/expression.view.html) expression function from [Simulation Aids](https://inductiveautomation.com/moduleshowcase/module/automation-professionals-llc-simulation-aids). (-:

---

<div class="post-metadata">

**Author:** ![dawei.liu](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@dawei.liu](https://forum.inductiveautomation.com/u/dawei.liu)\
**Post date:** [September 10, 2019, 2:03am UTC](https://forum.inductiveautomation.com/t/search-historian-with-where-clause/23541/3 "2019-09-10T02:03:52Z")

</div>

@pturmel  
For your view() expression function. Does it support Ignition 8.  
What’s the license of it?  
Can we use it free in commercial productions?

---

<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:** [September 10, 2019, 2:54am UTC](https://forum.inductiveautomation.com/t/search-historian-with-where-clause/23541/4 "2019-09-10T02:54:16Z")

</div>

Well… it _ **did** _ support v8, but broke somewhere around 8.0.2. It is a commercial license, not open source. But I offer it free to use, including in commercial solutions, with free but low-priority support (here on the forum and via email). Fixing it for v8.0.3+ is on my to do list, _real soon now_… /:

I deploy this on all of my paying customers’ servers, and fully support their use of it. Their upgrades to v8 will therefore make it a priority.

---

<div class="post-metadata">

**Author:** ![Andrew.Zebic](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Andrew.Zebic](https://forum.inductiveautomation.com/u/Andrew.Zebic)\
**Post date:** [September 10, 2019, 6:29am UTC](https://forum.inductiveautomation.com/t/search-historian-with-where-clause/23541/5 "2019-09-10T06:29:52Z")

</div>

Hi @TimE,

Why don’t you just use a query with a where clause? I think it would go something like:

```auto
SELECT myColumns 
FROM myTables 
WHERE tagid = myTags 
AND floatvalue > myLowerValue
AND floatvalue < myUpperValue

```

If you want to make it dynamic you could script the query as you want.

---

<div class="post-metadata">

**Author:** ![dawei.liu](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@dawei.liu](https://forum.inductiveautomation.com/u/dawei.liu)\
**Post date:** [September 10, 2019, 12:02pm UTC](https://forum.inductiveautomation.com/t/search-historian-with-where-clause/23541/6 "2019-09-10T12:02:50Z")

</div>

@pturmel  
Thanks for your suggestion  
We downloaded the file and install it. It seems not work on ignition 8.0.4 Nightly.

As workaround, we will use a for loop in python script to find the expected cell in the dataset, even it maybe a little lower efficient than the select function of view() expression.

---

<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:** [September 12, 2019, 5:01pm UTC](https://forum.inductiveautomation.com/t/search-historian-with-where-clause/23541/7 "2019-09-12T17:01:42Z")

</div>

Updated Simulation Aids module tested against v8.0.3 is available here:

[https://www.automation-pros.com/ignition/Simulation%20Aids-1.7.8.1909121622-v8.modl](https://www.automation-pros.com/ignition/Simulation%20Aids-1.7.8.1909121622-v8.modl)

Please report any problems you have with it.
