# Tag History Binding or Named Query

**URL:** <https://forum.inductiveautomation.com/t/tag-history-binding-or-named-query/68330>\
**Category:** Ignition\
**Created:** [January 6, 2023, 9:40pm UTC](https://forum.inductiveautomation.com/t/tag-history-binding-or-named-query/68330 "2023-01-06T21:40:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anthony\_ho](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anthony\_ho](https://forum.inductiveautomation.com/u/anthony_ho)\
**Post date:** [January 6, 2023, 9:40pm UTC](https://forum.inductiveautomation.com/t/tag-history-binding-or-named-query/68330/1 "2023-01-06T21:40:59Z")

</div>

We have SQL Server with monthly partitions logging analog every 5 seconds. The QA user would like to select any time range and find out the percentage of temperature above the setpoint during the hot rinse is on. I am trying to use Tag History Binding or Named Query. But it seems I can't use conditions in the expression and if I use Named Query, I will have to union an unknown number of tables.

The logic is  
if({Water\_Temp\_Fahrenheit} \> {Water\_Temp\_Setpoint} && ({Hot\_Water\_Rinse} = 1 || {Hot\_Water\_Rinse} = 1), true, false)

Should I use Tag History Binding Wide/Tall/Calculations PointCount/AsStored? Or is there a better way to do this?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/a/fabcd46644227c55308fe427a8e8976d23330751.png)

---

<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:** [January 6, 2023, 10:10pm UTC](https://forum.inductiveautomation.com/t/tag-history-binding-or-named-query/68330/2 "2023-01-06T22:10:50Z")

</div>

This is one of those situations that is trivial to solve when using transaction groups (or scripts) to store rows instead of using tag history (which is columnar).

Consider scripting a continuous analysis of 1-minute or 5-minute or 1-hour intervals and storing the results in an easy-to-query wide table.

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [January 7, 2023, 9:38am UTC](https://forum.inductiveautomation.com/t/tag-history-binding-or-named-query/68330/3 "2023-01-07T09:38:38Z")

</div>

I use an expression boolean variable with per minute historian and similar logic. And count True value in the time range. It's a little slow, but pretty easy.
