# Adding column to table with query bound dataset

**URL:** <https://forum.inductiveautomation.com/t/adding-column-to-table-with-query-bound-dataset/52849>\
**Category:** Ignition\
**Created:** [November 8, 2021, 8:35pm UTC](https://forum.inductiveautomation.com/t/adding-column-to-table-with-query-bound-dataset/52849 "2021-11-08T20:35:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [November 8, 2021, 8:35pm UTC](https://forum.inductiveautomation.com/t/adding-column-to-table-with-query-bound-dataset/52849/1 "2021-11-08T20:35:58Z")

</div>

Is there a way to add another column to a table with a dataset from a transaction group?

I want to match the code from the first column to text that I would put in the added column.

The text associated with the code number is not in my transaction group.  
Like if I know 2101 means the part is too small, and I want my table to also show the reason.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [November 8, 2021, 8:40pm UTC](https://forum.inductiveautomation.com/t/adding-column-to-table-with-query-bound-dataset/52849/2 "2021-11-08T20:40:49Z")

</div>

You can use system.dataset.addColumn() to do this.  
[https://docs.inductiveautomation.com/display/DOC81/system.dataset.addColumn](https://docs.inductiveautomation.com/display/DOC81/system.dataset.addColumn)

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [November 8, 2021, 8:45pm UTC](https://forum.inductiveautomation.com/t/adding-column-to-table-with-query-bound-dataset/52849/3 "2021-11-08T20:45:03Z")

</div>

thanks

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [November 8, 2021, 10:02pm UTC](https://forum.inductiveautomation.com/t/adding-column-to-table-with-query-bound-dataset/52849/4 "2021-11-08T22:02:48Z")

</div>

If you’re querying a database you can also add it to your query. Something like:

```auto
SELECT
  statusInt,
  CASE statusInt
    WHEN 1 THEN 'ON'
    WHEN 2 THEN 'OFF'
    ELSE 'ERROR'
    END as explanation,
  colA,
  colB
FROM tableA

```

There might be a better way than CASE. If there is I’m sure someone will suggest it.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 9, 2021, 11:11am UTC](https://forum.inductiveautomation.com/t/adding-column-to-table-with-query-bound-dataset/52849/5 "2021-11-09T11:11:23Z")

</div>

An oft-used method would be to create another db table with the codes and descriptions on it, the use a JOIN clause in the query

```sql
SELECT table1.col1, table1.col2, table1.status, table2.description
FROM table1
LEFT JOIN table2 ON table1.status = table2.status

```

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [November 9, 2021, 5:16pm UTC](https://forum.inductiveautomation.com/t/adding-column-to-table-with-query-bound-dataset/52849/6 "2021-11-09T17:16:28Z")

</div>

that seems very efficient

what is the good way to create the table?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 9, 2021, 5:37pm UTC](https://forum.inductiveautomation.com/t/adding-column-to-table-with-query-bound-dataset/52849/7 "2021-11-09T17:37:24Z")

</div>

Your DB tool of choice (Management Studio, Workbench, DataGrip, et al) is fine. This, generally speaking, would be a static table, once all your codes are in.
