# Table Column Select

**URL:** <https://forum.inductiveautomation.com/t/table-column-select/3583>\
**Category:** Ignition\
**Created:** [November 10, 2011, 8:10pm UTC](https://forum.inductiveautomation.com/t/table-column-select/3583 "2011-11-10T20:10:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joseph\_Mendonca](https://avatars.discourse-cdn.com/v4/letter/j/58f4c7/32.png) [@Joseph\_Mendonca](https://forum.inductiveautomation.com/u/Joseph_Mendonca)\
**Post date:** [November 10, 2011, 8:10pm UTC](https://forum.inductiveautomation.com/t/table-column-select/3583/1 "2011-11-10T20:10:33Z")

</div>

We have an historical transaction group db table that consists of multiple columns, (siteXXXgalstoday, siteXXXgalsyesterday, siteXXXgalsweek, etc.) for at least 75 sites. Is there a way to dynamically extract these statistics pertinent to one site into a table dataset from a sql query or do I need to manipulate the dataset? I looked for a way to do a select column dynamically from an sql query but was not successful.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [November 10, 2011, 8:35pm UTC](https://forum.inductiveautomation.com/t/table-column-select/3583/2 "2011-11-10T20:35:01Z")

</div>

Well, if your columns are named like that consistently for each site you can create a dynamic SQL query by sticking in the site. Something like:`SELECT 
    {Root Container.SiteName}galstoday,
    {Root Container.SiteName}galsyesterday,
...`Where the {Root Container.SiteName} just points to a property that contains the site name. You can replace that with a dropdown list or whatever you need.

---

<div class="post-metadata">

**Author:** ![Joseph\_Mendonca](https://avatars.discourse-cdn.com/v4/letter/j/58f4c7/32.png) [@Joseph\_Mendonca](https://forum.inductiveautomation.com/u/Joseph_Mendonca)\
**Post date:** [November 10, 2011, 10:51pm UTC](https://forum.inductiveautomation.com/t/table-column-select/3583/3 "2011-11-10T22:51:03Z")

</div>

Works great! Exactly what we needed. Thanks
